mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* don't report changed when nothing is removed
* add change log
* linter happy
* Update plugins/modules/files/ini_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update changelogs/fragments/4154-ini_file_changed.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* add absent idempotency test
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f527bb61f9
)
Co-authored-by: James Livulpi <james.livulpi@me.com>
This commit is contained in:
parent
a110f6eb4b
commit
316b36862f
3 changed files with 14 additions and 3 deletions
2
changelogs/fragments/4154-ini_file_changed.yml
Normal file
2
changelogs/fragments/4154-ini_file_changed.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- ini_file - when removing nothing do not report changed (https://github.com/ansible-collections/community.general/issues/4154).
|
|
@ -367,9 +367,10 @@ def do_ini(module, filename, section=None, option=None, values=None,
|
|||
section_lines = new_section_lines
|
||||
else:
|
||||
# drop the entire section
|
||||
section_lines = []
|
||||
msg = 'section removed'
|
||||
changed = True
|
||||
if section_lines:
|
||||
section_lines = []
|
||||
msg = 'section removed'
|
||||
changed = True
|
||||
|
||||
# reassemble the ini_lines after manipulation
|
||||
ini_lines = before + section_lines + after
|
||||
|
|
|
@ -504,6 +504,13 @@
|
|||
state: absent
|
||||
register: result20
|
||||
|
||||
- name: test-values 20 - remove section 'drinks' again to ensure idempotency"
|
||||
ini_file:
|
||||
path: "{{ output_file }}"
|
||||
section: drinks
|
||||
state: absent
|
||||
register: result20_remove_again
|
||||
|
||||
- name: test-values 20 - read content from output file
|
||||
slurp:
|
||||
src: "{{ output_file }}"
|
||||
|
@ -517,6 +524,7 @@
|
|||
assert:
|
||||
that:
|
||||
- result20 is changed
|
||||
- result20_remove_again is not changed
|
||||
- result20.msg == 'section removed'
|
||||
- content20 == "\n"
|
||||
|
||||
|
|
Loading…
Reference in a new issue