From d5a759b2e33ddbde7c7b848292be5ee36f35d3fc Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 13:38:43 +0200 Subject: [PATCH] [PR #11765/2297a5c8 backport][stable-12] Ensure standard locale in run_command (group4-batch1) (#11792) Ensure standard locale in run_command (group4-batch1) (#11765) * ensure standard locale in run_command (group4) Adds ``LANGUAGE=C`` and ``LC_ALL=C`` to the ``environ_update`` passed to ``run_command()`` calls in modules that parse command output, to prevent locale-dependent parsing failures on non-C-locale systems. Modules updated: dconf, pkgng, terraform. * add changelog fragment for group4 * add PR link to group4 changelog fragment * fix changelog fragment: rename with PR prefix, fix URL order --------- (cherry picked from commit 2297a5c876f0062450c0cea145ec848f482e31e3) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- changelogs/fragments/11765-group4-locale.yml | 4 ++++ plugins/modules/dconf.py | 2 +- plugins/modules/pkgng.py | 4 ++-- plugins/modules/terraform.py | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/11765-group4-locale.yml diff --git a/changelogs/fragments/11765-group4-locale.yml b/changelogs/fragments/11765-group4-locale.yml new file mode 100644 index 0000000000..7ef548fb22 --- /dev/null +++ b/changelogs/fragments/11765-group4-locale.yml @@ -0,0 +1,4 @@ +bugfixes: + - dconf - 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/11765). + - pkgng - 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/11765). + - terraform - 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/11765). diff --git a/plugins/modules/dconf.py b/plugins/modules/dconf.py index e79004ad0d..8db0547bdc 100644 --- a/plugins/modules/dconf.py +++ b/plugins/modules/dconf.py @@ -311,7 +311,7 @@ class DconfPreference: """ command = [self.dconf_bin, "read", key] - rc, out, err = self.module.run_command(command) + rc, out, err = self.module.run_command(command, environ_update={"LANGUAGE": "C", "LC_ALL": "C"}) if rc != 0: self.module.fail_json(msg=f"dconf failed while reading the value with error: {err}", out=out, err=err) diff --git a/plugins/modules/pkgng.py b/plugins/modules/pkgng.py index d9db694c16..e7eec1c463 100644 --- a/plugins/modules/pkgng.py +++ b/plugins/modules/pkgng.py @@ -156,7 +156,7 @@ def query_update(module, run_pkgng, name): def pkgng_older_than(module, pkgng_path, compare_version): - rc, out, err = module.run_command([pkgng_path, "-v"]) + rc, out, err = module.run_command([pkgng_path, "-v"], environ_update={"LANGUAGE": "C", "LC_ALL": "C"}) version = [int(x) for x in re.split(r"[\._]", out)] i = 0 @@ -455,7 +455,7 @@ def main(): ): args = ("-g",) + args - pkgng_env = {"BATCH": "yes"} + pkgng_env = {"BATCH": "yes", "LANGUAGE": "C", "LC_ALL": "C"} if p["ignore_osver"]: pkgng_env["IGNORE_OSVERSION"] = "yes" diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index 2588736b69..e9aeea86e9 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -528,6 +528,8 @@ def main(): supports_check_mode=True, ) + module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"} + project_path = module.params.get("project_path") bin_path = module.params.get("binary_path") plugin_paths = module.params.get("plugin_paths")