diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index d4e4beaa38..8124eb9a70 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2606,10 +2606,10 @@ class AnsibleModule(object): if use_unsafe_shell: args = " ".join([shlex_quote(x) for x in args]) shell = True - elif isinstance(args, (binary_type, text_type)) and use_unsafe_shell: - shell = True elif isinstance(args, (binary_type, text_type)): - if not use_unsafe_shell: + if use_unsafe_shell: + shell = True + else: # On python2.6 and below, shlex has problems with text type # On python3, shlex needs a text type. if PY2: