Adding a config option to allow disabling locale settings upon module exec

Fixes #15138
pull/15315/head
James Cammarata 9 years ago
parent edab8d338d
commit 040893a677

@ -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
===========

@ -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.

@ -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)

@ -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(
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()

Loading…
Cancel
Save