From 677008bef7f179ab411dd6e17c44522a4d898195 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 13 Mar 2014 13:51:10 -0500 Subject: [PATCH] Rejoin args list into a string for run_command when using an unsafe shell This allows the use of an args list with leading environment variables, which otherwise would fail due to the way Popen works. --- lib/ansible/module_utils/basic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 069bee6224..7da09908eb 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1009,7 +1009,9 @@ class AnsibleModule(object): shell = False if isinstance(args, list): - pass + if use_unsafe_shell: + args = " ".join([pipes.quote(x) for x in args]) + shell = True elif isinstance(args, basestring) and use_unsafe_shell: shell = True elif isinstance(args, basestring):