From 3ef5b3606642c442c9f8946b7a2db9db00a9682d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 22:29:04 +0200 Subject: [PATCH] [PR #11773/8fbb43e6 backport][stable-12] Ensure standard locale in run_command (group5-batch2) (#11806) Ensure standard locale in run_command (group5-batch2) (#11773) * ensure standard locale in run_command (group5-batch2) Adds ``LANGUAGE=C`` and ``LC_ALL=C`` to ``run_command()`` calls in modules that parse command output, to prevent locale-dependent parsing failures on non-C-locale systems. Modules updated: cronvar, dnf_versionlock, dpkg_divert, flatpak_remote, hg. * add changelog fragment for group5-batch2 --------- (cherry picked from commit 8fbb43e6602efe4ed8db48fd240f267d087510e9) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- changelogs/fragments/11773-group5-batch2-locale.yml | 6 ++++++ plugins/modules/cronvar.py | 1 + plugins/modules/dnf_versionlock.py | 1 + plugins/modules/dpkg_divert.py | 1 + plugins/modules/flatpak_remote.py | 1 + plugins/modules/hg.py | 1 + 6 files changed, 11 insertions(+) create mode 100644 changelogs/fragments/11773-group5-batch2-locale.yml diff --git a/changelogs/fragments/11773-group5-batch2-locale.yml b/changelogs/fragments/11773-group5-batch2-locale.yml new file mode 100644 index 0000000000..701ee81429 --- /dev/null +++ b/changelogs/fragments/11773-group5-batch2-locale.yml @@ -0,0 +1,6 @@ +bugfixes: + - cronvar - ensure ``LANGUAGE=C`` and ``LC_ALL=C`` are set when running commands that parse output (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11773). + - dnf_versionlock - ensure ``LANGUAGE=C`` and ``LC_ALL=C`` are set when running commands that parse output (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11773). + - dpkg_divert - ensure ``LANGUAGE=C`` and ``LC_ALL=C`` are set when running commands that parse output (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11773). + - flatpak_remote - ensure ``LANGUAGE=C`` and ``LC_ALL=C`` are set when running commands that parse output (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11773). + - hg - ensure ``LANGUAGE=C`` and ``LC_ALL=C`` are set when running commands that parse output (https://github.com/ansible-collections/community.general/issues/11737, https://github.com/ansible-collections/community.general/pull/11773). diff --git a/plugins/modules/cronvar.py b/plugins/modules/cronvar.py index a1c60c2d0f..3ef6f0b0f9 100644 --- a/plugins/modules/cronvar.py +++ b/plugins/modules/cronvar.py @@ -360,6 +360,7 @@ def main(): mutually_exclusive=[["insertbefore", "insertafter"]], supports_check_mode=False, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} name = module.params["name"] value = module.params["value"] diff --git a/plugins/modules/dnf_versionlock.py b/plugins/modules/dnf_versionlock.py index 7095fb102a..c6c15fee1a 100644 --- a/plugins/modules/dnf_versionlock.py +++ b/plugins/modules/dnf_versionlock.py @@ -257,6 +257,7 @@ def main(): ), supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} patterns = module.params["name"] raw = module.params["raw"] diff --git a/plugins/modules/dpkg_divert.py b/plugins/modules/dpkg_divert.py index 1fcf144b86..19896640e1 100644 --- a/plugins/modules/dpkg_divert.py +++ b/plugins/modules/dpkg_divert.py @@ -171,6 +171,7 @@ def main(): ), supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} path = module.params["path"] state = module.params["state"] diff --git a/plugins/modules/flatpak_remote.py b/plugins/modules/flatpak_remote.py index 5d54acc35f..81c01d0fe1 100644 --- a/plugins/modules/flatpak_remote.py +++ b/plugins/modules/flatpak_remote.py @@ -199,6 +199,7 @@ def main(): # This module supports check mode supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} name = module.params["name"] flatpakrepo_url = module.params["flatpakrepo_url"] diff --git a/plugins/modules/hg.py b/plugins/modules/hg.py index 14e6de9720..73eef182a0 100644 --- a/plugins/modules/hg.py +++ b/plugins/modules/hg.py @@ -219,6 +219,7 @@ def main(): executable=dict(type="str"), ), ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} repo = module.params["repo"] dest = module.params["dest"] revision = module.params["revision"]