From f5fd32eae671963e66475cbe66cad6cfa6d017d3 Mon Sep 17 00:00:00 2001 From: Andrew Shewmaker Date: Mon, 22 May 2017 15:39:57 -0700 Subject: [PATCH] docker_container: do not split command on commas (#24900) * docker_container: do not split command on commas Fix issue #24430 * docker_container: document command parameter Prior behavior was strange, splitting strings on commas only to join them again ... replacing commas with spaces. FYI, docker-py accepts strings or lists, using shlex.split on strings ... splitting on spaces while respecting things like quotes. https://github.com/docker/docker-py/blob/master/docker/api/container.py https://github.com/docker/docker-py/blob/master/docker/types/containers.py https://github.com/docker/docker-py/blob/master/docker/utils/utils.py More info regarding Dockerfile syntax for CMD strings and lists can be found at https://docs.docker.com/engine/reference/builder/#cmd --- lib/ansible/modules/cloud/docker/docker_container.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 4056348872c..d2787d2f9b9 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -59,6 +59,8 @@ options: command: description: - Command to execute when the container starts. + A command may be either a string or a list. + Prior to version 2.4, strings were split on commas. default: null required: false cpu_period: @@ -814,7 +816,8 @@ class TaskParameters(DockerBaseClass): if self.command: # convert from list to str - self.command = ' '.join([str(x) for x in self.command]) + if isinstance(self.command, list): + self.command = ' '.join([str(x) for x in self.command]) def fail(self, msg): self.client.module.fail_json(msg=msg) @@ -1970,7 +1973,7 @@ def main(): blkio_weight=dict(type='int'), capabilities=dict(type='list'), cleanup=dict(type='bool', default=False), - command=dict(type='list'), + command=dict(type='raw'), cpu_period=dict(type='int'), cpu_quota=dict(type='int'), cpuset_cpus=dict(type='str'),