mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-14 21:01:13 +00:00
[PR #11768/b40608a3 backport][stable-12] Ensure standard locale in run_command (group5-batch1) (#11795)
Ensure standard locale in run_command (group5-batch1) (#11768)
* ensure standard locale in run_command (group5-batch1)
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: apache2_module, composer, facter_facts, known_hosts module
utils, lvg_rename, macports, modprobe, monit, open_iscsi, pacman_key,
rhsm_release, rpm_ostree_pkg, sysupgrade.
* add changelog fragment for group5-batch1
* Remove lvg_rename from locale fix — superseded by PR #11746
PR #11746 (feat: use CmdRunner for LVM commands) takes priority and
will handle lvg_rename.py via CmdRunner refactor. Removing our
run_command_environ_update change to avoid conflict.
---------
(cherry picked from commit b40608a39d)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
changelogs/fragments/11768-group5-batch1-locale.yml
Normal file
13
changelogs/fragments/11768-group5-batch1-locale.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
bugfixes:
|
||||
- apache2_module - 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/11768).
|
||||
- composer - 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/11768).
|
||||
- facter_facts - 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/11768).
|
||||
- known_hosts module utils - 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/11768).
|
||||
- macports - 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/11768).
|
||||
- modprobe - 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/11768).
|
||||
- monit - 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/11768).
|
||||
- open_iscsi - 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/11768).
|
||||
- pacman_key - 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/11768).
|
||||
- rhsm_release - 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/11768).
|
||||
- rpm_ostree_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/11768).
|
||||
- sysupgrade - 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/11768).
|
||||
@@ -152,7 +152,7 @@ def add_host_key(module, fqdn, port=22, key_type="rsa", create_dir=False):
|
||||
else:
|
||||
this_cmd = f"{keyscan_cmd} -t {key_type} {fqdn}"
|
||||
|
||||
rc, out, err = module.run_command(this_cmd)
|
||||
rc, out, err = module.run_command(this_cmd, environ_update={"LANGUAGE": "C", "LC_ALL": "C"})
|
||||
# ssh-keyscan gives a 0 exit code and prints nothing on timeout
|
||||
if rc != 0 or not out:
|
||||
msg = "failed to retrieve hostkey"
|
||||
|
||||
@@ -245,6 +245,7 @@ def main():
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
name = module.params["name"]
|
||||
if name == "cgi" and module.params["state"] == "present" and _run_threaded(module):
|
||||
|
||||
@@ -227,6 +227,7 @@ def main():
|
||||
required_if=[("global_command", False, ["working_dir"])],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
# Get composer command with fallback to default
|
||||
command = module.params["command"]
|
||||
|
||||
@@ -69,6 +69,7 @@ def main():
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
facter_path = module.get_bin_path("facter", opt_dirs=["/opt/puppetlabs/bin"])
|
||||
|
||||
|
||||
@@ -271,6 +271,7 @@ def main():
|
||||
variant=dict(aliases=["variants"], type="str"),
|
||||
)
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
stdout = ""
|
||||
stderr = ""
|
||||
|
||||
@@ -298,6 +298,7 @@ def build_module():
|
||||
|
||||
def main():
|
||||
module = build_module()
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
modprobe = Modprobe(module)
|
||||
|
||||
|
||||
@@ -322,6 +322,7 @@ def main():
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
name = module.params["name"]
|
||||
state = module.params["state"]
|
||||
|
||||
@@ -390,6 +390,7 @@ def main():
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
global iscsiadm_cmd
|
||||
iscsiadm_cmd = module.get_bin_path("iscsiadm", required=True)
|
||||
|
||||
@@ -361,6 +361,7 @@ def main():
|
||||
mutually_exclusive=(("data", "file", "url", "keyserver"),),
|
||||
required_if=[("state", "present", ("data", "file", "url", "keyserver"), True)],
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
PacmanKey(module)
|
||||
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ def main():
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
if os.getuid() != 0:
|
||||
module.fail_json(msg="Interacting with subscription-manager requires root permissions ('become: true')")
|
||||
|
||||
@@ -190,6 +190,7 @@ def main():
|
||||
),
|
||||
),
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
|
||||
rpm_ostree_pkg = RpmOstreePkg(module)
|
||||
rpm_ostree_pkg.ensure()
|
||||
|
||||
@@ -133,6 +133,7 @@ def main():
|
||||
),
|
||||
supports_check_mode=False,
|
||||
)
|
||||
module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
|
||||
return_dict = sysupgrade_run(module)
|
||||
module.exit_json(**return_dict)
|
||||
|
||||
|
||||
@@ -117,4 +117,4 @@ def test_add_host_key(mocker, fqdn, port, add_host_key_cmd):
|
||||
mocker.patch("os.path.exists", return_value=True)
|
||||
|
||||
known_hosts.add_host_key(am, fqdn, port=port)
|
||||
run_command.assert_called_with(keyscan_cmd + add_host_key_cmd)
|
||||
run_command.assert_called_with(keyscan_cmd + add_host_key_cmd, environ_update={"LANGUAGE": "C", "LC_ALL": "C"})
|
||||
|
||||
Reference in New Issue
Block a user