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 <noreply@anthropic.com>

* Add changelog fragment for PR #11776

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky
2026-04-13 08:02:18 +12:00
committed by GitHub
parent 7c52f1c41d
commit e45e6cbb5d
6 changed files with 21 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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