summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-03-25 12:22:45 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-03-25 12:24:49 -0700
commitaaa25eb75c84662d0d496188e143bc616e60ecc5 (patch)
treef5f12a20a2c56cb74e8dddafd2877eb816112216
parentc024057e9721f8736068b5fb5743ff8b18f6248e (diff)
downloadansible-aaa25eb75c84662d0d496188e143bc616e60ecc5.tar.gz
Make run_command() work when we get byte str with non-ascii characters (instead of unicode type like we were expecting)
Fix and test. Fixes #10536
-rw-r--r--lib/ansible/module_utils/basic.py7
-rw-r--r--test/integration/unicode.yml9
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index b68a36b9c6..ad1d43f86c 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -1457,7 +1457,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
diff --git a/test/integration/unicode.yml b/test/integration/unicode.yml
index b04d760182..1044c25270 100644
--- a/test/integration/unicode.yml
+++ b/test/integration/unicode.yml
@@ -41,6 +41,15 @@
- name: 'A task with unicode host vars'
debug: var=unicode_host_var
+ - name: 'A task with unicode shell parameters'
+ shell: echo '¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö ×'
+ register: output
+
+ - name: 'Assert that the unicode was echoed'
+ assert:
+ that:
+ - "'¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö ×' in output.stdout_lines"
+
- name: 'A play for hosts in group: ĪīĬĭ'
hosts: 'ĪīĬĭ'
gather_facts: true