1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pam_limits: adds both check and diff modes (#830)

* pam_limits: adds check mode

fixes #827

* pam_limits: adds diff mode

fixes #828
This commit is contained in:
♫ Christian Krause ♫ 2021-01-03 11:11:06 +01:00 committed by GitHub
parent ce83bde742
commit 777d36b9fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -0,0 +1,3 @@
minor_changes:
- pam_limits - adds check mode (https://github.com/ansible-collections/community.general/issues/827).
- pam_limits - adds diff mode (https://github.com/ansible-collections/community.general/issues/828).

View file

@ -176,7 +176,8 @@ def main():
backup=dict(default=False, type='bool'),
dest=dict(default=limits_conf, type='str'),
comment=dict(required=False, default='', type='str')
)
),
supports_check_mode=True,
)
domain = module.params['domain']
@ -315,8 +316,15 @@ def main():
f.close()
nf.flush()
# Copy tempfile to newfile
module.atomic_move(nf.name, f.name)
with open(limits_conf, 'r') as content:
content_current = content.read()
with open(nf.name, 'r') as content:
content_new = content.read()
if not module.check_mode:
# Copy tempfile to newfile
module.atomic_move(nf.name, limits_conf)
try:
nf.close()
@ -324,7 +332,9 @@ def main():
pass
res_args = dict(
changed=changed, msg=message
changed=changed,
msg=message,
diff=dict(before=content_current, after=content_new),
)
if backup: