From 60f972dfe4bc58180c666f820ef2d602acf917e4 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 25 Mar 2015 13:57:48 -0700 Subject: [PATCH] Fix the command module handling of non-ascii values. We can't depend on the args being unicode text because we're in module land, not in the ansible controller land --- v2/ansible/module_utils/basic.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/v2/ansible/module_utils/basic.py b/v2/ansible/module_utils/basic.py index 79a0fab67b..b3cebf0ba5 100644 --- a/v2/ansible/module_utils/basic.py +++ b/v2/ansible/module_utils/basic.py @@ -1433,7 +1433,7 @@ class AnsibleModule(object): msg = None st_in = None - # Set a temporart env path if a prefix is passed + # Set a temporary env path if a prefix is passed env=os.environ if path_prefix: env['PATH']="%s:%s" % (path_prefix, env['PATH']) @@ -1442,7 +1442,12 @@ class AnsibleModule(object): # in reporting later, which strips out things like # passwords from the args list if isinstance(args, basestring): - to_clean_args = shlex.split(args.encode('utf-8')) + if isinstance(args, unicode): + b_args = args.encode('utf-8') + else: + b_args = args + to_clean_args = shlex.split(b_args) + del b_args else: to_clean_args = args