mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-10 20:01:40 +00:00
[PR #12014/b8659f5c backport][stable-12] pam_limits: only create backup file when content actually changes (#12020)
pam_limits: only create backup file when content actually changes (#12014)
* fix(pam_limits): only create backup when file is actually changed
Fixes #12011
* changelog: add fragment for PR 12014
---------
(cherry picked from commit b8659f5c61)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b3669957d9
commit
b1d88ae3c1
2 changed files with 7 additions and 5 deletions
2
changelogs/fragments/12014-pam_limits-backup.yml
Normal file
2
changelogs/fragments/12014-pam_limits-backup.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "pam_limits - only create backup file when the target file is actually modified (https://github.com/ansible-collections/community.general/issues/12011, https://github.com/ansible-collections/community.general/pull/12014)."
|
||||
|
|
@ -235,10 +235,7 @@ def main():
|
|||
|
||||
_assert_is_valid_value(module, limit_item, value)
|
||||
|
||||
# Backup
|
||||
if backup:
|
||||
backup_file = module.backup_local(limits_conf)
|
||||
|
||||
backup_file = None
|
||||
space_pattern = re.compile(r"\s+")
|
||||
|
||||
if does_not_exist:
|
||||
|
|
@ -356,6 +353,9 @@ def main():
|
|||
with open(limits_conf, "a"):
|
||||
pass
|
||||
|
||||
if backup and changed and not does_not_exist:
|
||||
backup_file = module.backup_local(limits_conf)
|
||||
|
||||
# Move tempfile to newfile
|
||||
module.atomic_move(os.path.abspath(nf.name), os.path.abspath(limits_conf))
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ def main():
|
|||
diff=dict(before=b"".join(lines), after=content_new),
|
||||
)
|
||||
|
||||
if backup:
|
||||
if backup_file:
|
||||
res_args["backup_file"] = backup_file
|
||||
|
||||
module.exit_json(**res_args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue