mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
* Controlled params within no section * Added tests to control params within no section * Cleaning output_file before creating no-section params and check the content * addresses comment in PR "s/hate/beverage/g"
This commit is contained in:
parent
2162d7d4de
commit
d3fe6c01f2
2 changed files with 115 additions and 6 deletions
|
@ -171,9 +171,22 @@ def do_ini(module, filename, section=None, option=None, value=None,
|
|||
ini_lines[-1] += '\n'
|
||||
changed = True
|
||||
|
||||
# append a fake section line to simplify the logic
|
||||
# append fake section lines to simplify the logic
|
||||
# At top:
|
||||
# Fake random section to do not match any other in the file
|
||||
# Using commit hash as fake section name
|
||||
fake_section_name = "ad01e11446efb704fcdbdb21f2c43757423d91c5"
|
||||
|
||||
# Insert it at the beginning
|
||||
ini_lines.insert(0, '[%s]' % fake_section_name)
|
||||
|
||||
# At botton:
|
||||
ini_lines.append('[')
|
||||
|
||||
# If no section is defined, fake section is used
|
||||
if not section:
|
||||
section = fake_section_name
|
||||
|
||||
within_section = not section
|
||||
section_start = 0
|
||||
msg = 'OK'
|
||||
|
@ -241,6 +254,7 @@ def do_ini(module, filename, section=None, option=None, value=None,
|
|||
break
|
||||
|
||||
# remove the fake section line
|
||||
del ini_lines[0]
|
||||
del ini_lines[-1:]
|
||||
|
||||
if not within_section and option and state == 'present':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue