ansible.builtin.ini (v2.7.18) — lookup

read data from a ini file

| "added in version" 2.0 of ansible.builtin"

Authors: Yannig Perre <yannig.perre(at)gmail.com>

Install Ansible via pip

Install with pip install ansible==2.7.18

Description

The ini lookup reads the contents of a file in INI format C(key1=value1). This plugin retrieve the value on the right side after the equal sign C('=') of a given section C([section]).

You can also read a property file which - in this case - does not contain section.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="User in integration is {{ lookup('ini', 'user section=integration file=users.ini') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="User in production  is {{ lookup('ini', 'user section=production  file=users.ini') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="user.name is {{ lookup('ini', 'user.name type=properties file=user.properties') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: "{{ item }}"
  with_ini:
    - value[1-2]
    - section: section1
    - file: "lookup.ini"
    - re: true

Inputs

    
re:
    default: false
    description: Flag to indicate if the key supplied is a regexp.
    type: boolean

file:
    default: ansible.ini
    description: Name of the file to load

type:
    choices:
    - ini
    - properties
    default: ini
    description: ini Type of the file. 'properties' refers to the Java properties files.

_terms:
    description: The key(s) to look up
    required: true

default:
    default: ''
    description: return value if the key is not in the ini file

section:
    default: global
    description: section where to lookup for key.

encoding:
    default: utf-8
    description: Text encoding to use.

Outputs

_raw:
  description:
  - value(s) of the key(s) in the ini file