diff --git a/lib/ansible/modules/extras/system/pam_limits.py b/lib/ansible/modules/extras/system/pam_limits.py index efc3301d11..f6542a85bf 100644 --- a/lib/ansible/modules/extras/system/pam_limits.py +++ b/lib/ansible/modules/extras/system/pam_limits.py @@ -225,11 +225,16 @@ def main(): nf.write(new_limit) f.close() - nf.close() + nf.flush() # Copy tempfile to newfile module.atomic_move(nf.name, f.name) + try: + nf.close() + except: + pass + res_args = dict( changed = changed, msg = message )