mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
disabled appending file with garbage when regexp didn't match.
This commit is contained in:
parent
50461a686c
commit
2e4c02f93e
1 changed files with 5 additions and 1 deletions
|
@ -184,10 +184,14 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create, backu
|
||||||
# Add it to the end of the file if requested or
|
# Add it to the end of the file if requested or
|
||||||
# if insertafter=/insertbefore didn't match anything
|
# if insertafter=/insertbefore didn't match anything
|
||||||
# (so default behaviour is to add at the end)
|
# (so default behaviour is to add at the end)
|
||||||
elif insertafter == 'EOF' or index[1] == -1:
|
elif insertafter == 'EOF':
|
||||||
lines.append(line + os.linesep)
|
lines.append(line + os.linesep)
|
||||||
msg = 'line added'
|
msg = 'line added'
|
||||||
changed = True
|
changed = True
|
||||||
|
# Do nothing if regexp didn't match
|
||||||
|
elif index[1] == -1:
|
||||||
|
msg = ''
|
||||||
|
changed = False
|
||||||
# insertafter/insertbefore= matched
|
# insertafter/insertbefore= matched
|
||||||
else:
|
else:
|
||||||
lines.insert(index[1], line + os.linesep)
|
lines.insert(index[1], line + os.linesep)
|
||||||
|
|
Loading…
Reference in a new issue