pamd: add delete=False to NamedTemporaryFile() (#47281)

* add delete=False to NamedTemporaryFile and remove print statement from module

* add changelog fragment

* use module.tmpdir from (#47133) and add changelog fragment for it as well

(cherry picked from commit c67ab296bb)
This commit is contained in:
Daniel Shepherd 2018-10-19 10:46:47 -04:00 committed by Toshio Kuratomi
parent b618339c32
commit 1a4604361f
3 changed files with 10 additions and 2 deletions

View file

@ -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)"

View file

@ -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)"

View file

@ -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))