There are several great ways to read, write and modify INI files using Ansible, I linked to them in this comment, .ini
/ .conf
/ .env
file lookup, fliters and modules:
- community.general.ini_file module
- ansible.builtin.ini lookup
- community.general.to_ini filter
- community.general.from_ini filter
JC INI parsers that can be used with the JC filter :
I’d suggest using these rather than lineinfile
.