community.general.ini_file – Tweak settings in INI files¶
Note
This plugin is part of the community.general collection (version 2.5.1).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.ini_file
.
Synopsis¶
Manage (add, remove, change) individual settings in an INI-style file without having to manage the file as a whole with, say, ansible.builtin.template or ansible.builtin.assemble.
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.
Parameters¶
Notes¶
Note
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.
Examples¶
# 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
Authors¶
Jan-Piet Mens (@jpmens)
Ales Nosek (@noseka1)