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)