ansible.ini_file(3) - Linux man page
Name
ini_file - Tweak settings in INI files
Description
Manage (add, remove, change) individual settings in an INI-style file without having to manage the file as a whole with, say, template or assemble. Adds missing sections if they don't exist.
Options
- backup
Create a backup file including the timestamp
- information so you can get the original file back if you somehow clobbered it incorrectly. Choices: yes,no.
- dest
Path to the INI-style file; this file is created if required(required)
option
if set (required for changing a value), this is the name of the option.May be omitted if adding/removing a whole section.
others
all arguments accepted by the file module also work here
- section
- information so you can get the original file back if you somehow clobbered it incorrectly. Choices: yes,no.
- Section name in INI file. This is added if state=present automatically when a single value is being set.(required)
- value
the string value to be associated with an option. May be omitted when removing an option.."
Notes
While it is possible to add an option without specifying a value, this makes no sense.
A section named default cannot be added by the module, but if it exists, individual options within the section can be updated. (This is a limitation of Python's ConfigParser.) Either use template to create a base INI file with a [default] section, or use lineinfile to add the missing line.
Examples
Ensure fav=lemonade is in section [drinks] in said file
ini_file: dest=/etc/conf section=drinks option=fav value=lemonade mode=0600 backup=yes
ini_file: dest=/etc/anotherconf
section=drinks
option=temperature
value=cold
backup=yes
Author
Jan-Piet Mens