ansible / ansible.builtin / v2.9.13 / lookup / ini read data from a ini file | "added in version" 2.0 of ansible.builtin" Authors: Yannig Perre <yannig.perre(at)gmail.com>ansible.builtin.ini (v2.9.13) — lookup
pip
Install with pip install ansible==2.9.13
The ini lookup reads the contents of a file in INI format C(key1=value1). This plugin retrieves 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.
- debug: msg="User in integration is {{ lookup('ini', 'user section=integration file=users.ini') }}"
- debug: msg="User in production is {{ lookup('ini', 'user section=production file=users.ini') }}"
- debug: msg="user.name is {{ lookup('ini', 'user.name type=properties file=user.properties') }}"
- debug: msg: "{{ item }}" with_ini: - '.* section=section1 file=test.ini re=True'
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: 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 the key. encoding: default: utf-8 description: Text encoding to use.
_raw: description: - value(s) of the key(s) in the ini file