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:
parent
ce83bde742
commit
777d36b9fb
2 changed files with 17 additions and 4 deletions
3
changelogs/fragments/830-pam-limits.yml
Normal file
3
changelogs/fragments/830-pam-limits.yml
Normal 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).
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue