pam_limits: adds both check and diff modes (#830)
* pam_limits: adds check mode fixes #827 * pam_limits: adds diff mode fixes #828pull/1575/head
parent
ce83bde742
commit
777d36b9fb
|
@ -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'),
|
backup=dict(default=False, type='bool'),
|
||||||
dest=dict(default=limits_conf, type='str'),
|
dest=dict(default=limits_conf, type='str'),
|
||||||
comment=dict(required=False, default='', type='str')
|
comment=dict(required=False, default='', type='str')
|
||||||
)
|
),
|
||||||
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
domain = module.params['domain']
|
domain = module.params['domain']
|
||||||
|
@ -315,8 +316,15 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
nf.flush()
|
nf.flush()
|
||||||
|
|
||||||
# Copy tempfile to newfile
|
with open(limits_conf, 'r') as content:
|
||||||
module.atomic_move(nf.name, f.name)
|
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:
|
try:
|
||||||
nf.close()
|
nf.close()
|
||||||
|
@ -324,7 +332,9 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
res_args = dict(
|
res_args = dict(
|
||||||
changed=changed, msg=message
|
changed=changed,
|
||||||
|
msg=message,
|
||||||
|
diff=dict(before=content_current, after=content_new),
|
||||||
)
|
)
|
||||||
|
|
||||||
if backup:
|
if backup:
|
||||||
|
|
Loading…
Reference in New Issue