mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Fix #22130 (ini_file crash when destination file don't exists or is empty)
This commit is contained in:
parent
61288b14fd
commit
22d657d3c7
1 changed files with 4 additions and 0 deletions
|
@ -176,6 +176,10 @@ def do_ini(module, filename, section=None, option=None, value=None,
|
|||
|
||||
changed = False
|
||||
|
||||
# ini file could be empty
|
||||
if not ini_lines:
|
||||
ini_lines.append('\n')
|
||||
|
||||
# last line of file may not contain a trailing newline
|
||||
if ini_lines[-1] == "" or ini_lines[-1][-1] != '\n':
|
||||
ini_lines[-1] += '\n'
|
||||
|
|
Loading…
Reference in a new issue