diff --git a/changelogs/fragments/47133-pamd_use_module_tmpdir.yml b/changelogs/fragments/47133-pamd_use_module_tmpdir.yml new file mode 100644 index 0000000000..419c55b493 --- /dev/null +++ b/changelogs/fragments/47133-pamd_use_module_tmpdir.yml @@ -0,0 +1,4 @@ +--- +bugfixes: +- "pamd: use module.tmpdir for NamedTemporaryFile() + (see https://github.com/ansible/ansible/pull/47133 and https://github.com/ansible/ansible/issues/36954)" 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..9bd9df0ec6 --- /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)" diff --git a/lib/ansible/modules/system/pamd.py b/lib/ansible/modules/system/pamd.py index ab0319b679..a09eb0b4a4 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') + temp_file = NamedTemporaryFile(mode='w', dir=module.tmpdir, delete=False) with open(temp_file.name, 'w') as fd: fd.write(str(service))