From 9f9e936d3c4ffe0b60c12bec75d0b5b1af9a42f3 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Mon, 6 Aug 2018 14:46:40 -0500 Subject: [PATCH] Force all args to strings for 'command' (fixes #43732) --- lib/ansible/modules/commands/command.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/commands/command.py b/lib/ansible/modules/commands/command.py index 5a814c1ece6..28bd4a59aea 100644 --- a/lib/ansible/modules/commands/command.py +++ b/lib/ansible/modules/commands/command.py @@ -133,6 +133,8 @@ import os import shlex from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_native +from ansible.module_utils.common.collections import is_iterable def check_command(module, commandline): @@ -215,6 +217,10 @@ def main(): args = args or argv + # All args must be strings + if is_iterable(args, include_strings=False): + args = [to_native(arg, errors='surrogate_or_strict', nonstring='simplerepr') for arg in args] + if chdir: chdir = os.path.abspath(chdir) os.chdir(chdir)