From 40ce650d08738772f0dfea002a0e6e38f3c0c068 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 20 Apr 2024 10:08:18 +0200 Subject: [PATCH] [PR #8001/1b8e6bc9 backport][stable-7] puppet_utils: Do not force lang for cmd (#8241) puppet_utils: Do not force lang for cmd (#8001) puppet_utils: Add option to set LANG for puppet execution Add option `environment_lang` to force the LANG when executing the puppet agent. The default is the `C` LANG (cherry picked from commit 1b8e6bc95bd3cc749ea65b8d713b1facc1db0c7e) Co-authored-by: Niklas Schwarz --- changelogs/fragments/puppet_lang_force.yml | 3 +++ plugins/module_utils/puppet.py | 1 + plugins/modules/puppet.py | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 changelogs/fragments/puppet_lang_force.yml diff --git a/changelogs/fragments/puppet_lang_force.yml b/changelogs/fragments/puppet_lang_force.yml new file mode 100644 index 0000000000..b826c8dba4 --- /dev/null +++ b/changelogs/fragments/puppet_lang_force.yml @@ -0,0 +1,3 @@ +bugfixes: + - puppet - add option ``environment_lang`` to set the environment language encoding. Defaults to lang ``C``. It is recommended + to set it to ``C.UTF-8`` or ``en_US.UTF-8`` depending on what is available on your system. (https://github.com/ansible-collections/community.general/issues/8000) diff --git a/plugins/module_utils/puppet.py b/plugins/module_utils/puppet.py index 8d553a2d28..f05b0673f6 100644 --- a/plugins/module_utils/puppet.py +++ b/plugins/module_utils/puppet.py @@ -107,5 +107,6 @@ def puppet_runner(module): verbose=cmd_runner_fmt.as_bool("--verbose"), ), check_rc=False, + force_lang=module.params["environment_lang"], ) return runner diff --git a/plugins/modules/puppet.py b/plugins/modules/puppet.py index 86eac062a8..b28583fe05 100644 --- a/plugins/modules/puppet.py +++ b/plugins/modules/puppet.py @@ -116,6 +116,15 @@ options: - Whether to print file changes details type: bool default: false + environment_lang: + description: + - The lang environment to use when running the puppet agent. + - The default value, V(C), is supported on every system, but can lead to encoding errors if UTF-8 is used in the output + - Use V(C.UTF-8) or V(en_US.UTF-8) or similar UTF-8 supporting locales in case of problems. You need to make sure + the selected locale is supported on the system the puppet agent runs on. + type: str + default: C + version_added: 8.6.0 requirements: - puppet author: @@ -208,6 +217,7 @@ def main(): debug=dict(type='bool', default=False), verbose=dict(type='bool', default=False), use_srv_records=dict(type='bool'), + environment_lang=dict(type='str', default='C'), ), supports_check_mode=True, mutually_exclusive=[