From 5f0a9bba0119e205e1dd5f3bc510894d92fbafba Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 13 Apr 2026 07:58:52 +1200 Subject: [PATCH] Ensure standard locale in run_command (group5-batch10) (#11781) * Fix locale env vars in run_command() calls for group5 batch10 modules Set LANGUAGE=C and LC_ALL=C via run_command_environ_update to ensure locale-independent output parsing in imgadm, smartos_image_info, syspatch, portage, portinstall, xbps, and lbu. Co-Authored-By: Claude Sonnet 4.6 * Add changelog fragment for PR #11781 Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- .../fragments/11781-group5-batch10-locale.yml | 22 +++++++++++++++++++ plugins/modules/imgadm.py | 1 + plugins/modules/lbu.py | 1 + plugins/modules/portage.py | 1 + plugins/modules/portinstall.py | 1 + plugins/modules/smartos_image_info.py | 1 + plugins/modules/syspatch.py | 1 + plugins/modules/xbps.py | 1 + 8 files changed, 29 insertions(+) create mode 100644 changelogs/fragments/11781-group5-batch10-locale.yml diff --git a/changelogs/fragments/11781-group5-batch10-locale.yml b/changelogs/fragments/11781-group5-batch10-locale.yml new file mode 100644 index 0000000000..748e862d82 --- /dev/null +++ b/changelogs/fragments/11781-group5-batch10-locale.yml @@ -0,0 +1,22 @@ +bugfixes: + - imgadm - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - lbu - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - portage - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - portinstall - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - smartos_image_info - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - syspatch - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). + - xbps - set ``LANGUAGE`` and ``LC_ALL`` to ``C`` in ``run_command()`` calls to ensure locale-independent output parsing + (https://github.com/ansible-collections/community.general/issues/11737, + https://github.com/ansible-collections/community.general/pull/11781). diff --git a/plugins/modules/imgadm.py b/plugins/modules/imgadm.py index 1a60b9ef47..b6a708044f 100644 --- a/plugins/modules/imgadm.py +++ b/plugins/modules/imgadm.py @@ -276,6 +276,7 @@ def main(): # provide a "noop" (or equivalent) mode to do a dry-run. supports_check_mode=False, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} imgadm = Imgadm(module) diff --git a/plugins/modules/lbu.py b/plugins/modules/lbu.py index a136f1cab1..6f2152f7ee 100644 --- a/plugins/modules/lbu.py +++ b/plugins/modules/lbu.py @@ -86,6 +86,7 @@ def run_module(): }, supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} changed = False diff --git a/plugins/modules/portage.py b/plugins/modules/portage.py index 5a6727f9f6..790aaade5b 100644 --- a/plugins/modules/portage.py +++ b/plugins/modules/portage.py @@ -587,6 +587,7 @@ def main(): ], supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} if not HAS_PORTAGE: if sys.executable != "/usr/bin/python" and not has_respawned(): diff --git a/plugins/modules/portinstall.py b/plugins/modules/portinstall.py index cf0a3174e4..fa0a6261a4 100644 --- a/plugins/modules/portinstall.py +++ b/plugins/modules/portinstall.py @@ -191,6 +191,7 @@ def main(): use_packages=dict(type="bool", default=True), ) ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} p = module.params diff --git a/plugins/modules/smartos_image_info.py b/plugins/modules/smartos_image_info.py index 194c0b1efc..3c5dafb3c5 100644 --- a/plugins/modules/smartos_image_info.py +++ b/plugins/modules/smartos_image_info.py @@ -109,6 +109,7 @@ def main(): ), supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} image_facts = ImageFacts(module) diff --git a/plugins/modules/syspatch.py b/plugins/modules/syspatch.py index 3095c7750f..15473c3db5 100644 --- a/plugins/modules/syspatch.py +++ b/plugins/modules/syspatch.py @@ -75,6 +75,7 @@ def run_module(): argument_spec=module_args, supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} result = syspatch_run(module) diff --git a/plugins/modules/xbps.py b/plugins/modules/xbps.py index 76e3ff8078..5bc050bfd8 100644 --- a/plugins/modules/xbps.py +++ b/plugins/modules/xbps.py @@ -361,6 +361,7 @@ def main(): required_one_of=[["name", "update_cache", "upgrade"]], supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} xbps_path = dict() xbps_path["install"] = module.get_bin_path("xbps-install", True)