diff --git a/lib/ansible/modules/system/pamd.py b/lib/ansible/modules/system/pamd.py index e2e04e0863c..ef83108d8f6 100644 --- a/lib/ansible/modules/system/pamd.py +++ b/lib/ansible/modules/system/pamd.py @@ -778,7 +778,7 @@ def main(): backupdest = module.backup_local(fname) print("BACKUP DEST", backupdest) try: - temp_file = NamedTemporaryFile(mode='w') + temp_file = NamedTemporaryFile(mode='w', dir=module.tmpdir) with open(temp_file.name, 'w') as fd: fd.write(str(service))