1.6 KiB
1.6 KiB
ansible.builtin.ini
The ini lookup reads the contents of a file in INI format key1=value1
. This plugin retrieves the value on the right side after the equal sign '='
of a given section [section]
.
Parameters
Parameter | Type | Description |
---|---|---|
Input | string / required | The key(s) to look up. |
default | string | Return value if the key is not in the ini file. |
file | string | Name of the file to load. |
re | boolean | Flag to indicate if the key supplied is a regexp. |
section | string | Section where to lookup the key. |
Examples
- ansible.builtin.debug: msg="User in integration is {{ lookup('ansible.builtin.ini', 'user', section='integration', file='users.ini') }}"
- ansible.builtin.debug: msg="User in production is {{ lookup('ansible.builtin.ini', 'user', section='production', file='users.ini') }}"
- ansible.builtin.debug: msg="user.name is {{ lookup('ansible.builtin.ini', 'user.name', type='properties', file='user.properties') }}"
- ansible.builtin.debug:
msg: "{{ item }}"
loop: "{{ q('ansible.builtin.ini', '.*', section='section1', file='test.ini', re=True) }}"
- name: Read an ini file with allow_no_value
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.ini', 'user', file='mysql.ini', section='mysqld', allow_no_value=True) }}"