From d74e553f4b1e1f2613e6446703ed3cd2e11088b5 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 13:43:30 +0200 Subject: [PATCH] [PR #11767/f4f2bfe8 backport][stable-12] openbsd_pkg, sorcery: ensure standard locale in run_command (group4-batch2) (#11793) openbsd_pkg, sorcery: ensure standard locale in run_command (group4-batch2) (#11767) * ensure standard locale in run_command (group4-batch2) 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: openbsd_pkg, sorcery. * add changelog fragment for group4-batch2 * add changelog fragment for group4-batch2 --------- (cherry picked from commit f4f2bfe847b586c04cb21e25c3d41131f3590ac0) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- changelogs/fragments/11767-group4-batch2-locale.yml | 3 +++ plugins/modules/openbsd_pkg.py | 2 +- plugins/modules/sorcery.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11767-group4-batch2-locale.yml diff --git a/changelogs/fragments/11767-group4-batch2-locale.yml b/changelogs/fragments/11767-group4-batch2-locale.yml new file mode 100644 index 0000000000..3bf469895d --- /dev/null +++ b/changelogs/fragments/11767-group4-batch2-locale.yml @@ -0,0 +1,3 @@ +bugfixes: + - openbsd_pkg - 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/11767). + - sorcery - 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/11767). diff --git a/plugins/modules/openbsd_pkg.py b/plugins/modules/openbsd_pkg.py index 699a67f084..2b84c4d422 100644 --- a/plugins/modules/openbsd_pkg.py +++ b/plugins/modules/openbsd_pkg.py @@ -166,7 +166,7 @@ def execute_command(cmd, module): # We set TERM to 'dumb' to keep pkg_add happy if the machine running # ansible is using a TERM that the managed machine does not know about, # e.g.: "No progress meter: failed termcap lookup on xterm-kitty". - return module.run_command(cmd_args, environ_update={"TERM": "dumb"}) + return module.run_command(cmd_args, environ_update={"TERM": "dumb", "LANGUAGE": "C", "LC_ALL": "C"}) def get_all_installed(module): diff --git a/plugins/modules/sorcery.py b/plugins/modules/sorcery.py index 4fe6596615..a29934f76c 100644 --- a/plugins/modules/sorcery.py +++ b/plugins/modules/sorcery.py @@ -703,7 +703,7 @@ def main(): SORCERY[c] = module.get_bin_path(c, True) # prepare environment: run sorcery commands without asking questions - module.run_command_environ_update = dict(PROMPT_DELAY="0", VOYEUR="0") + module.run_command_environ_update = dict(PROMPT_DELAY="0", VOYEUR="0", LANGUAGE="C", LC_ALL="C") params = module.params