summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2016-02-07 12:45:03 -0800
committerToshio Kuratomi <toshio@fedoraproject.org>2016-02-07 13:07:28 -0800
commit43fdc6aee3aa80415d123bc4b3d43aa59b94bfc2 (patch)
treef16ff67d7472344b14e05f185d876273de8d2faf
parentf1033f2194d227f471b9c40b89610ab3310edd15 (diff)
downloadansible-43fdc6aee3aa80415d123bc4b3d43aa59b94bfc2.tar.gz
Allow setting run_command environment overrides for the life of an AnsibleModule
-rw-r--r--lib/ansible/module_utils/basic.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 012b6652ff..5a84ec92c5 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -355,7 +355,10 @@ class AnsibleModule(object):
self.check_mode = False
self.no_log = no_log
self.cleanup_files = []
-
+ # May be used to set modifications to the environment for any
+ # run_command invocation
+ self.run_command_environ_update = {}
+
self.aliases = {}
if add_file_common_args:
@@ -1467,6 +1470,10 @@ class AnsibleModule(object):
# Manipulate the environ we'll send to the new process
old_env_vals = {}
+ # We can set this from both an attribute and per call
+ for key, val in self.run_command_environ_update.items():
+ old_env_vals[key] = os.environ.get(key, None)
+ os.environ[key] = val
if environ_update:
for key, val in environ_update.items():
old_env_vals[key] = os.environ.get(key, None)