From 2e94affde652c9c3977782fd1d391dd2a4ffe6bd Mon Sep 17 00:00:00 2001 From: Victor Beresnev Date: Thu, 21 Jan 2016 15:23:29 +0400 Subject: [PATCH] If cmd and entrypoint not set, don't match them Hello! I wanted stop the containers matched only by image name, but can't do this, if I not set cmd in playbook. This behavior confused me. If cmd or entrypoint is defined for running container, but not defined in playbook, makes matching behavior as this sample: https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker/docker.py#L463 --- lib/ansible/modules/cloud/docker/docker.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index e342d3f0c8c..a70aa7e3cfe 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -1548,10 +1548,17 @@ class DockerManager(object): image_matches = running_image in repo_tags - command_matches = command == details['Config']['Cmd'] - entrypoint_matches = ( - entrypoint == details['Config']['Entrypoint'] - ) + if command == None: + command_matches = True + else: + command_matches = (command == details['Config']['Cmd']) + + if entrypoint == None: + entrypoint_matches = True + else: + entrypoint_matches = ( + entrypoint == details['Config']['Entrypoint'] + ) matches = (image_matches and command_matches and entrypoint_matches)