From e59888dd7ee47a2967f67bdd76eae850248555a4 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Thu, 9 Apr 2026 01:21:58 +1200 Subject: [PATCH] Ensure standard locale in run_command (group3-batch3) (#11741) * run_command locale group3 batch3: normalise to LANGUAGE=C, LC_ALL=C Co-Authored-By: Claude Sonnet 4.6 * fix changelog fragment: bugfixes, American English, separate code spans Co-Authored-By: Claude Sonnet 4.6 * fix changelog fragment: correct PR number (11741) Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- .../11741-run-command-locale-group3-batch3.yml | 9 +++++++++ plugins/modules/pkgin.py | 2 +- plugins/modules/redhat_subscription.py | 2 +- plugins/modules/rhsm_repository.py | 2 +- plugins/modules/runit.py | 2 +- plugins/modules/supervisorctl.py | 2 +- plugins/modules/svc.py | 2 +- plugins/modules/ufw.py | 2 +- plugins/modules/zypper.py | 2 +- tests/unit/plugins/modules/test_redhat_subscription.py | 10 +++++----- 10 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/11741-run-command-locale-group3-batch3.yml diff --git a/changelogs/fragments/11741-run-command-locale-group3-batch3.yml b/changelogs/fragments/11741-run-command-locale-group3-batch3.yml new file mode 100644 index 0000000000..26a1c8ebf4 --- /dev/null +++ b/changelogs/fragments/11741-run-command-locale-group3-batch3.yml @@ -0,0 +1,9 @@ +bugfixes: + - pkgin - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - redhat_subscription - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - rhsm_repository - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - runit - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - supervisorctl - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - svc - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - ufw - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). + - zypper - normalize locale environment for ``run_command()`` calls to ``LANGUAGE=C``, ``LC_ALL=C`` (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11741). diff --git a/plugins/modules/pkgin.py b/plugins/modules/pkgin.py index 06b7d0ebbd..d4759b9f14 100644 --- a/plugins/modules/pkgin.py +++ b/plugins/modules/pkgin.py @@ -353,7 +353,7 @@ def main(): global PKGIN_PATH PKGIN_PATH = module.get_bin_path("pkgin", True, ["/opt/local/bin"]) - module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C", LC_CTYPE="C") + module.run_command_environ_update = dict(LANGUAGE="C", LC_ALL="C") p = module.params diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 20c7cbe4d4..179e5f2b20 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -931,7 +931,7 @@ class RhsmPools: args += " --consumed" else: args += " --available" - lang_env = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C") + lang_env = dict(LANGUAGE="C", LC_ALL="C") rc, stdout, stderr = self.module.run_command(args, check_rc=True, environ_update=lang_env) products = [] diff --git a/plugins/modules/rhsm_repository.py b/plugins/modules/rhsm_repository.py index 8b7e5eeccf..00f644ba6f 100644 --- a/plugins/modules/rhsm_repository.py +++ b/plugins/modules/rhsm_repository.py @@ -93,7 +93,7 @@ class Rhsm: self.module = module self.rhsm_bin = self.module.get_bin_path("subscription-manager", required=True) self.rhsm_kwargs = { - "environ_update": dict(LANG="C", LC_ALL="C", LC_MESSAGES="C"), + "environ_update": dict(LANGUAGE="C", LC_ALL="C"), "expand_user_and_vars": False, "use_unsafe_shell": False, } diff --git a/plugins/modules/runit.py b/plugins/modules/runit.py index 4a8ec97fc5..9075665a35 100644 --- a/plugins/modules/runit.py +++ b/plugins/modules/runit.py @@ -225,7 +225,7 @@ def main(): supports_check_mode=True, ) - module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C", LC_CTYPE="C") + module.run_command_environ_update = dict(LANGUAGE="C", LC_ALL="C") state = module.params["state"] enabled = module.params["enabled"] diff --git a/plugins/modules/supervisorctl.py b/plugins/modules/supervisorctl.py index 2fe370949d..e67974d1c3 100644 --- a/plugins/modules/supervisorctl.py +++ b/plugins/modules/supervisorctl.py @@ -153,7 +153,7 @@ def main(): signal = module.params.get("signal") # we check error message for a pattern, so we need to make sure that's in C locale - module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C", LC_CTYPE="C") + module.run_command_environ_update = dict(LANGUAGE="C", LC_ALL="C") if supervisorctl_path: if os.path.exists(supervisorctl_path) and is_executable(supervisorctl_path): diff --git a/plugins/modules/svc.py b/plugins/modules/svc.py index 6005620451..0f71f30072 100644 --- a/plugins/modules/svc.py +++ b/plugins/modules/svc.py @@ -255,7 +255,7 @@ def main(): supports_check_mode=True, ) - module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C", LC_CTYPE="C") + module.run_command_environ_update = dict(LANGUAGE="C", LC_ALL="C") state = module.params["state"] enabled = module.params["enabled"] diff --git a/plugins/modules/ufw.py b/plugins/modules/ufw.py index 3b69924d36..f1d840551c 100644 --- a/plugins/modules/ufw.py +++ b/plugins/modules/ufw.py @@ -395,7 +395,7 @@ def main(): cmd = " ".join(map(itemgetter(-1), filter(itemgetter(0), cmd))) cmds.append(cmd) - (rc, out, err) = module.run_command(cmd, environ_update={"LANG": "C"}) + (rc, out, err) = module.run_command(cmd, environ_update={"LANGUAGE": "C", "LC_ALL": "C"}) if rc != 0 and not ignore_error: module.fail_json(msg=err or out, commands=cmds) diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index 1a2e8de6c2..7b57302f90 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -624,7 +624,7 @@ def main(): supports_check_mode=True, ) - module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C") + module.run_command_environ_update = dict(LANGUAGE="C", LC_ALL="C") name = module.params["name"] state = module.params["state"] diff --git a/tests/unit/plugins/modules/test_redhat_subscription.py b/tests/unit/plugins/modules/test_redhat_subscription.py index 55b24a8ae5..6437fff2d8 100644 --- a/tests/unit/plugins/modules/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/test_redhat_subscription.py @@ -449,7 +449,7 @@ TEST_CASES = [ ( [ "subscription-manager list --available", - {"check_rc": True, "environ_update": {"LANG": "C", "LC_ALL": "C", "LC_MESSAGES": "C"}}, + {"check_rc": True, "environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}}, ( 0, """ @@ -559,7 +559,7 @@ Entitlement Type: Physical ( [ "subscription-manager list --available", - {"check_rc": True, "environ_update": {"LANG": "C", "LC_ALL": "C", "LC_MESSAGES": "C"}}, + {"check_rc": True, "environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}}, ( 0, """ @@ -655,7 +655,7 @@ Entitlement Type: Physical ( [ "subscription-manager list --available", - {"check_rc": True, "environ_update": {"LANG": "C", "LC_ALL": "C", "LC_MESSAGES": "C"}}, + {"check_rc": True, "environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}}, ( 0, """ @@ -733,7 +733,7 @@ Entitlement Type: Physical ), ( "subscription-manager list --consumed", - {"check_rc": True, "environ_update": {"LANG": "C", "LC_ALL": "C", "LC_MESSAGES": "C"}}, + {"check_rc": True, "environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}}, ( 0, """ @@ -776,7 +776,7 @@ Entitlement Type: Physical ( [ "subscription-manager list --available", - {"check_rc": True, "environ_update": {"LANG": "C", "LC_ALL": "C", "LC_MESSAGES": "C"}}, + {"check_rc": True, "environ_update": {"LANGUAGE": "C", "LC_ALL": "C"}}, ( 0, """