diff --git a/docsite/rst/intro_configuration.rst b/docsite/rst/intro_configuration.rst index 0a1c537cf6..3391c1f651 100644 --- a/docsite/rst/intro_configuration.rst +++ b/docsite/rst/intro_configuration.rst @@ -479,8 +479,22 @@ different locations:: Most users will not need to use this feature. See :doc:`developing_plugins` for more details +.. _module_set_locale: + +module_set_locale +================= + +This boolean value controls whether or not Ansible will prepend locale-specific environment variables (as specified +via the :doc:`module_lang` configuration option). By default this is enabled, and results in the LANG and LC_MESSAGES +being set when the module is executed on the given remote system. + +.. note:: + + The module_set_locale option was added in Ansible 2.1. + .. _module_lang: + module_lang =========== diff --git a/examples/ansible.cfg b/examples/ansible.cfg index f0236d6ad6..672c99dfc3 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -22,6 +22,7 @@ #transport = smart #remote_port = 22 #module_lang = C +#module_set_locale = True # plays will gather facts by default, which contain information about # the remote system. diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 393598c3fe..cd7659a0c6 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -140,6 +140,7 @@ DEFAULT_MODULE_NAME = get_config(p, DEFAULTS, 'module_name', None, DEFAULT_FORKS = get_config(p, DEFAULTS, 'forks', 'ANSIBLE_FORKS', 5, integer=True) DEFAULT_MODULE_ARGS = get_config(p, DEFAULTS, 'module_args', 'ANSIBLE_MODULE_ARGS', '') DEFAULT_MODULE_LANG = get_config(p, DEFAULTS, 'module_lang', 'ANSIBLE_MODULE_LANG', os.getenv('LANG', 'en_US.UTF-8')) +DEFAULT_MODULE_SET_LOCALE = get_config(p, DEFAULTS, 'module_set_locale','ANSIBLE_MODULE_SET_LOCALE',True, boolean=True) DEFAULT_MODULE_COMPRESSION= get_config(p, DEFAULTS, 'module_compression', None, 'ZIP_DEFLATED') DEFAULT_TIMEOUT = get_config(p, DEFAULTS, 'timeout', 'ANSIBLE_TIMEOUT', 10, integer=True) DEFAULT_POLL_INTERVAL = get_config(p, DEFAULTS, 'poll_interval', 'ANSIBLE_POLL_INTERVAL', 15, integer=True) diff --git a/lib/ansible/plugins/shell/__init__.py b/lib/ansible/plugins/shell/__init__.py index bef4541039..c8224eaf7a 100644 --- a/lib/ansible/plugins/shell/__init__.py +++ b/lib/ansible/plugins/shell/__init__.py @@ -31,11 +31,15 @@ _USER_HOME_PATH_RE = re.compile(r'^~[_.A-Za-z0-9][-_.A-Za-z0-9]*$') class ShellBase(object): def __init__(self): - self.env = dict( - LANG = C.DEFAULT_MODULE_LANG, - LC_ALL = C.DEFAULT_MODULE_LANG, - LC_MESSAGES = C.DEFAULT_MODULE_LANG, - ) + self.env = dict() + if C.DEFAULT_MODULE_SET_LOCALE: + self.env.update( + dict( + LANG = C.DEFAULT_MODULE_LANG, + LC_ALL = C.DEFAULT_MODULE_LANG, + LC_MESSAGES = C.DEFAULT_MODULE_LANG, + ) + ) def env_prefix(self, **kwargs): env = self.env.copy()