summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-11-27 05:29:10 -0800
committerMichael DeHaan <michael.dehaan@gmail.com>2012-11-27 05:29:10 -0800
commit304d06a563fa5ae82afa5ff540edbfeb71786af4 (patch)
tree2c61adf16cc91b8d606a0dd2ce5dfca5a2850552
parentdd5a8474f839dff3d600d0ba09351db55f8c6672 (diff)
parent6a68d3813f5043e55ea798591421c8efa5e5460f (diff)
downloadansible-304d06a563fa5ae82afa5ff540edbfeb71786af4.tar.gz
Merge pull request #1689 from sfromm/issue1644
Set LANG in module_common.py
-rwxr-xr-xhacking/test-module2
-rw-r--r--lib/ansible/constants.py1
-rw-r--r--lib/ansible/module_common.py3
-rw-r--r--lib/ansible/runner/__init__.py2
4 files changed, 8 insertions, 0 deletions
diff --git a/hacking/test-module b/hacking/test-module
index 240eb130d9..4ccde5502c 100755
--- a/hacking/test-module
+++ b/hacking/test-module
@@ -84,6 +84,8 @@ def boilerplate_module(modfile, args):
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
encoded_args = "\"\"\"%s\"\"\"" % args.replace("\"","\\\"")
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
+ encoded_lang = "\"\"\"%s\"\"\"" % C.DEFAULT_MODULE_LANG
+ module_data = module_data.replace(module_common.REPLACER_LANG, encoded_lang)
module_data = module_data.replace('syslog.LOG_USER', "syslog.%s" % C.DEFAULT_SYSLOG_FACILITY)
modfile2_path = os.path.expanduser("~/.ansible_module_generated")
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index 85e3327764..6d63b5b53a 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -77,6 +77,7 @@ DEFAULT_MODULE_NAME = get_config(p, DEFAULTS, 'module_name', None,
DEFAULT_PATTERN = get_config(p, DEFAULTS, 'pattern', None, '*')
DEFAULT_FORKS = get_config(p, DEFAULTS, 'forks', 'ANSIBLE_FORKS', 5)
DEFAULT_MODULE_ARGS = get_config(p, DEFAULTS, 'module_args', 'ANSIBLE_MODULE_ARGS', '')
+DEFAULT_MODULE_LANG = get_config(p, DEFAULTS, 'module_lang', 'ANSIBLE_MODULE_LANG', 'C')
DEFAULT_TIMEOUT = get_config(p, DEFAULTS, 'timeout', 'ANSIBLE_TIMEOUT', 10)
DEFAULT_POLL_INTERVAL = get_config(p, DEFAULTS, 'poll_interval', 'ANSIBLE_POLL_INTERVAL', 15)
DEFAULT_REMOTE_USER = get_config(p, DEFAULTS, 'remote_user', 'ANSIBLE_REMOTE_USER', active_user)
diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py
index 2cdc12d5ec..27d45aed44 100644
--- a/lib/ansible/module_common.py
+++ b/lib/ansible/module_common.py
@@ -17,12 +17,14 @@
REPLACER = "#<<INCLUDE_ANSIBLE_MODULE_COMMON>>"
REPLACER_ARGS = "<<INCLUDE_ANSIBLE_MODULE_ARGS>>"
+REPLACER_LANG = "<<INCLUDE_ANSIBLE_MODULE_LANG>>"
MODULE_COMMON = """
# == BEGIN DYNAMICALLY INSERTED CODE ==
MODULE_ARGS = <<INCLUDE_ANSIBLE_MODULE_ARGS>>
+MODULE_LANG = <<INCLUDE_ANSIBLE_MODULE_LANG>>
BOOLEANS_TRUE = ['yes', 'on', '1', 'true', 1]
BOOLEANS_FALSE = ['no', 'off', '0', 'false', 0]
@@ -143,6 +145,7 @@ class AnsibleModule(object):
if add_file_common_args:
self.argument_spec.update(FILE_COMMON_ARGUMENTS)
+ os.environ['LANG'] = MODULE_LANG
(self.params, self.args) = self._load_params()
self._legal_inputs = []
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py
index 4fda5b2be6..7837e691a9 100644
--- a/lib/ansible/runner/__init__.py
+++ b/lib/ansible/runner/__init__.py
@@ -537,6 +537,8 @@ class Runner(object):
module_data = module_data.replace(module_common.REPLACER, module_common.MODULE_COMMON)
encoded_args = "\"\"\"%s\"\"\"" % module_args.replace("\"","\\\"")
module_data = module_data.replace(module_common.REPLACER_ARGS, encoded_args)
+ encoded_lang = "\"\"\"%s\"\"\"" % C.DEFAULT_MODULE_LANG
+ module_data = module_data.replace(module_common.REPLACER_LANG, encoded_lang)
if is_new_style:
facility = C.DEFAULT_SYSLOG_FACILITY
if 'ansible_syslog_facility' in inject: