From cd057ddcdb5169ffe5b60d11c675b5dd7eb9494d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 27 May 2026 12:48:57 +0200 Subject: [PATCH] [PR #12106/50046965 backport][stable-12] lxc_container: Fix create_script in plugins/module_utils/_lxc.py (#12110) lxc_container: Fix create_script in plugins/module_utils/_lxc.py (#12106) * Fix create_script in plugins/module_utils/_lxc.py * Added changelog fragment * Apply suggestions from code review - updated typing * Apply suggestion from code review - fixed docstring argument name * Apply suggestion from code review * Update plugins/module_utils/_lxc.py --------- (cherry picked from commit 50046965c900a89183c1ee4c70ffa96d1c3ed192) Co-authored-by: usbpc <3638901+usbpc@users.noreply.github.com> Co-authored-by: Kevin Holm Co-authored-by: Felix Fontein --- changelogs/fragments/12106-fix-lxc-create_script.yml | 2 ++ plugins/module_utils/_lxc.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/12106-fix-lxc-create_script.yml diff --git a/changelogs/fragments/12106-fix-lxc-create_script.yml b/changelogs/fragments/12106-fix-lxc-create_script.yml new file mode 100644 index 0000000000..93fcf082d3 --- /dev/null +++ b/changelogs/fragments/12106-fix-lxc-create_script.yml @@ -0,0 +1,2 @@ +bugfixes: + - lxc_container - fix ``create_script`` to accept a single tuple argument, resolving a ``TypeError`` that silently prevented ``container_command`` from being executed (https://github.com/ansible-collections/community.general/issues/11360, https://github.com/ansible-collections/community.general/pull/12106). diff --git a/plugins/module_utils/_lxc.py b/plugins/module_utils/_lxc.py index 8db257c83a..577dd99db1 100644 --- a/plugins/module_utils/_lxc.py +++ b/plugins/module_utils/_lxc.py @@ -30,17 +30,20 @@ popd """ -def create_script(command: str, module: AnsibleModule) -> None: +def create_script(arg_tuple: tuple[str, AnsibleModule]) -> None: """Write out a script onto a target. This method should be backward compatible with Python when executing from within the container. - :param command: command to run, this can be a script and can use spacing - with newlines as separation. - :param module: AnsibleModule to run commands with. + :param arg_tuple: a tuple of (command, module) where command is the command + to run (this can be a script and can use spacing with + newlines as separation) and module is the AnsibleModule + to run commands with. """ + command, module = arg_tuple + script_file = "" try: f = tempfile.NamedTemporaryFile(prefix="lxc-attach-script", delete=False, mode="wb")