From b8469d5c7a0b24978836d445502d735089293d3c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 15 May 2020 15:52:17 -0400 Subject: [PATCH] lineinfile - Use ANSIBLE_REMOTE_TMP for temporary file (#69543) --- changelogs/fragments/lineinfile-use-module-tempdir.yaml | 2 ++ lib/ansible/modules/lineinfile.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/lineinfile-use-module-tempdir.yaml diff --git a/changelogs/fragments/lineinfile-use-module-tempdir.yaml b/changelogs/fragments/lineinfile-use-module-tempdir.yaml new file mode 100644 index 00000000000..b209820bc17 --- /dev/null +++ b/changelogs/fragments/lineinfile-use-module-tempdir.yaml @@ -0,0 +1,2 @@ +bugfixes: + - lineinfile - use ``module.tmpdir`` to allow configuration of the remote temp directory (https://github.com/ansible/ansible/issues/68218) diff --git a/lib/ansible/modules/lineinfile.py b/lib/ansible/modules/lineinfile.py index d3094bede3c..2ffa8d74f1b 100644 --- a/lib/ansible/modules/lineinfile.py +++ b/lib/ansible/modules/lineinfile.py @@ -213,7 +213,7 @@ from ansible.module_utils._text import to_bytes, to_native def write_changes(module, b_lines, dest): - tmpfd, tmpfile = tempfile.mkstemp() + tmpfd, tmpfile = tempfile.mkstemp(dir=module.tmpdir) with os.fdopen(tmpfd, 'wb') as f: f.writelines(b_lines)