community.general.ini_file – Tweak settings in INI files¶
This plugin is part of the community.general collection.
To install it use:
ansible-galaxy collection install community.general.
To use it in a playbook, specify:
Adds missing sections if they don’t exist.
Before Ansible 2.0, comments are discarded when the source file is read, and therefore will not show up in the destination file.
Since Ansible 2.3, this module adds missing ending newlines to files to keep in line with the POSIX standard, even when no other modifications need to be applied.
While it is possible to add an option without specifying a value, this makes no sense.
As of Ansible 2.3, the dest option has been changed to path as default, but dest still works as well.
# Before Ansible 2.3, option 'dest' was used instead of 'path' - name: Ensure "fav=lemonade is in section "[drinks]" in specified file community.general.ini_file: path: /etc/conf section: drinks option: fav value: lemonade mode: '0600' backup: yes - name: Ensure "temperature=cold is in section "[drinks]" in specified file community.general.ini_file: path: /etc/anotherconf section: drinks option: temperature value: cold backup: yes