diff --git a/changelogs/fragments/47281-pamd-dont-delete-named_temporary_file_on_close.yaml b/changelogs/fragments/47281-pamd-dont-delete-named_temporary_file_on_close.yaml new file mode 100644 index 0000000000..cb4130948c --- /dev/null +++ b/changelogs/fragments/47281-pamd-dont-delete-named_temporary_file_on_close.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: +- "pamd: add delete=False to NamedTemporaryFile() fixes OSError on module completion, and + removes print statement from module code. + (see https://github.com/ansible/ansible/pull/47281 and https://github.com/ansible/ansible/issues/47080)" \ No newline at end of file diff --git a/lib/ansible/modules/system/pamd.py b/lib/ansible/modules/system/pamd.py index ef83108d8f..c2c7a55e5f 100644 --- a/lib/ansible/modules/system/pamd.py +++ b/lib/ansible/modules/system/pamd.py @@ -776,9 +776,8 @@ def main(): # First, create a backup if desired. if module.params['backup']: backupdest = module.backup_local(fname) - print("BACKUP DEST", backupdest) try: - temp_file = NamedTemporaryFile(mode='w', dir=module.tmpdir) + temp_file = NamedTemporaryFile(mode='w', dir=module.tmpdir, delete=False) with open(temp_file.name, 'w') as fd: fd.write(str(service))