From e45e6cbb5d49b6dd20c46bdcd0152b7831310e4f Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 13 Apr 2026 08:02:18 +1200 Subject: [PATCH] Ensure standard locale in run_command (group5-batch5) (#11776) * Fix locale env vars in run_command() calls for group5 batch5 modules Set LANGUAGE=C and LC_ALL=C via run_command_environ_update to ensure locale-independent output parsing in pnpm, sysrc, timezone, xattr, and yarn. Co-Authored-By: Claude Sonnet 4.6 * Add changelog fragment for PR #11776 Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- .../fragments/11776-group5-batch5-locale.yml | 16 ++++++++++++++++ plugins/modules/pnpm.py | 1 + plugins/modules/sysrc.py | 1 + plugins/modules/timezone.py | 1 + plugins/modules/xattr.py | 1 + plugins/modules/yarn.py | 1 + 6 files changed, 21 insertions(+) create mode 100644 changelogs/fragments/11776-group5-batch5-locale.yml diff --git a/changelogs/fragments/11776-group5-batch5-locale.yml b/changelogs/fragments/11776-group5-batch5-locale.yml new file mode 100644 index 0000000000..fbd1bad562 --- /dev/null +++ b/changelogs/fragments/11776-group5-batch5-locale.yml @@ -0,0 +1,16 @@ +bugfixes: + - pnpm - 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/11776). + - sysrc - 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/11776). + - timezone - 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/11776). + - xattr - 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/11776). + - yarn - 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/11776). diff --git a/plugins/modules/pnpm.py b/plugins/modules/pnpm.py index c60b3c6831..55d7d0f8ac 100644 --- a/plugins/modules/pnpm.py +++ b/plugins/modules/pnpm.py @@ -327,6 +327,7 @@ def main(): ) arg_spec["global"] = dict(default=False, type="bool") module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} name = module.params["name"] alias = module.params["alias"] diff --git a/plugins/modules/sysrc.py b/plugins/modules/sysrc.py index 50c0c48517..d593b6681c 100644 --- a/plugins/modules/sysrc.py +++ b/plugins/modules/sysrc.py @@ -119,6 +119,7 @@ class Sysrc(StateModuleHelper): if not re.match(r"^\w+$", self.vars.name, re.ASCII): self.module.fail_json(msg="Name may only contain alpha-numeric and underscore characters") + self.module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} self.sysrc = self.module.get_bin_path("sysrc", True) def _contains(self): diff --git a/plugins/modules/timezone.py b/plugins/modules/timezone.py index 65eae5a95b..a5ef6eb91e 100644 --- a/plugins/modules/timezone.py +++ b/plugins/modules/timezone.py @@ -863,6 +863,7 @@ def main(): required_one_of=[["hwclock", "name"]], supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} tz = Timezone(module) # Check the current state diff --git a/plugins/modules/xattr.py b/plugins/modules/xattr.py index b8843fb2ea..ae2c02c3ad 100644 --- a/plugins/modules/xattr.py +++ b/plugins/modules/xattr.py @@ -178,6 +178,7 @@ def main(): ), supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} path = module.params.get("path") namespace = module.params.get("namespace") key = module.params.get("key") diff --git a/plugins/modules/yarn.py b/plugins/modules/yarn.py index 935ccd5710..dde26d792f 100644 --- a/plugins/modules/yarn.py +++ b/plugins/modules/yarn.py @@ -280,6 +280,7 @@ def main(): ) arg_spec["global"] = dict(default=False, type="bool") module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} name = module.params["name"] path = module.params["path"]