Open staehler opened 1 year ago
- name: set options in ini file community.general.ini_file: path: "/tmp/test.ini" section: "test" option: "active" value: "true" #allow_no_value: true create: false state: present mode: 0640 exclusive: true
When exlusive: true is set, allow_no_value:true shows weird behaviour.
exlusive: true
allow_no_value:true
I would expect, that exclusive: true takes care, that the regarding option is only once in a section.
Bug Report
community.general.ini_file
$ ansible --version ansible [core 2.12.10] config file = /home/ttt/ansible.cfg configured module search path = ['/home/ttt/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/ttt/ansible5.10.0/lib64/python3.8/site-packages/ansible ansible collection location = /home/ttt/collections executable location = /home/ttt/ansible5.10.0/bin/ansible python version = 3.8.13 (default, Jun 14 2022, 17:49:07) [GCC 8.5.0 20210514 (Red Hat 8.5.0-13)] jinja version = 3.1.2 libyaml = True
$ ansible-galaxy collection list community.general # /home/ttt/ansible5.10.0/lib64/python3.8/site-packages/ansible_collections Collection Version ----------------- ------- community.general 4.8.3 # /home/ttt/ansible5.10.0/lib/python3.8/site-packages/ansible_collections Collection Version ----------------- ------- community.general 4.8.3 # /home/ttt/collections/ansible_collections Collection Version ----------------- ------- community.general 6.4.0
$ ansible-config dump --only-changed
RHEL 8
--- - name: test playbook hosts: localhost become: true tasks: - name: set options in splunk conf files (splunkOptionsOverwrite.yml) community.general.ini_file: path: "/tmp/test.ini" section: "test" option: "active" value: "true" allow_no_value: true create: false state: present mode: 0640 exclusive: true
Have a /tmp/test.ini like
[test] active = false
run the playbook and you will find in /tmp/test.ini the line active = true added, despite of exclusiv: true
active = true
exclusiv: true
[test] active = false active = true
Only one line with the option active = true should be in the file.
see above
Files identified in the description:
plugins/modules/ini_file.py
If these files are incorrect, please update the component name section of the description or use the !component bot command.
component name
!component
click here for bot help
cc @jpmens @noseka1 click here for bot help
Summary
When
exlusive: true
is set,allow_no_value:true
shows weird behaviour.I would expect, that exclusive: true takes care, that the regarding option is only once in a section.
Issue Type
Bug Report
Component Name
community.general.ini_file
Ansible Version
Community.general Version
Configuration
OS / Environment
RHEL 8
Steps to Reproduce
Have a /tmp/test.ini like
run the playbook and you will find in /tmp/test.ini the line
active = true
added, despite ofexclusiv: true
Expected Results
Only one line with the option
active = true
should be in the file.Actual Results
see above
Code of Conduct