From fbea88b9d93a8017ea69b13f646d9f74d6135a54 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 22 Apr 2013 21:29:15 -0400 Subject: [PATCH] Allow the environment string to be referenced by a bare variable name like: environment: foo --- lib/ansible/runner/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 7f8d11dd344..ca4f8925ebf 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -240,6 +240,8 @@ class Runner(object): if not self.environment: return "" enviro = template.template(self.basedir, self.environment, inject) + if isinstance(enviro, basestring) and enviro in inject: + enviro = inject[enviro] if type(enviro) != dict: raise errors.AnsibleError("environment must be a dictionary, received %s" % enviro) result = "" @@ -292,7 +294,7 @@ class Runner(object): if not shebang: raise errors.AnsibleError("module is missing interpreter line") - cmd = " ".join([environment_string, shebang.replace("#!",""), cmd]) + cmd = " ".join([environment_string.strip(), shebang.replace("#!","").strip(), cmd]) cmd = cmd.strip() if tmp.find("tmp") != -1 and C.DEFAULT_KEEP_REMOTE_FILES != '1' and not persist_files: