From df3540073c4dee1cac01acf3fa7e75df7ab2229a Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 10 Jun 2020 18:26:32 -0400 Subject: [PATCH] [stable-2.9] lineinfile - Use ANSIBLE_REMOTE_TMP for temporary file (#69543) (#69549) (cherry picked from commit b8469d5c7a) Co-authored-by: Sam Doran --- changelogs/fragments/lineinfile-use-module-tempdir.yaml | 2 ++ lib/ansible/modules/files/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/files/lineinfile.py b/lib/ansible/modules/files/lineinfile.py index 568c28abfdf..7edcc661bbe 100644 --- a/lib/ansible/modules/files/lineinfile.py +++ b/lib/ansible/modules/files/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)