1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-11 02:25:36 +00:00

[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 50046965c9)

Co-authored-by: usbpc <3638901+usbpc@users.noreply.github.com>
Co-authored-by: Kevin Holm <kevin@holm.dev>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2026-05-27 12:48:57 +02:00 committed by GitHub
parent b759173038
commit cd057ddcdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

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

View file

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