From 76aad71974d74f1214922d3b57da8a540f6c91a2 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman <rjeffman@redhat.com> Date: Wed, 30 Nov 2022 00:57:07 -0300 Subject: [PATCH] environment: Fix os.environ language setting. A combination of ansible-freeipa modifications and a newer version of IPA has brought a regression regarding different OS localization. For properly setting environment to use "C" language, as required by ansible-freeipa, the setting must be executed before importing the module 'ipaserver.dcerpc', so setting environment language was moved closer to the 'import os' statement, so that it is always set, as soon as possible. Note that 'import os' should always be imported before any FreeIPA module. --- plugins/module_utils/ansible_freeipa_module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py index 247f6e74..b71c78c9 100644 --- a/plugins/module_utils/ansible_freeipa_module.py +++ b/plugins/module_utils/ansible_freeipa_module.py @@ -32,6 +32,9 @@ __all__ = ["gssapi", "netaddr", "api", "ipalib_errors", "Env", "load_pem_x509_certificate", "DNSName", "getargspec"] import os +# ansible-freeipa requires locale to be C, IPA requires utf-8. +os.environ["LANGUAGE"] = "C" + import sys import operator import tempfile @@ -154,9 +157,6 @@ else: ANSIBLE_FREEIPA_MODULE_IMPORT_ERROR = None -# ansible-freeipa requires locale to be C, IPA requires utf-8. -os.environ["LANGUAGE"] = "C" - if six.PY3: unicode = str -- GitLab