From 480c364afd972f61d2ec4544058b7f5da23ec56b Mon Sep 17 00:00:00 2001 From: Abdul Anshad A Date: Wed, 16 Nov 2016 08:57:49 +0530 Subject: [PATCH] fixes issue #5517 (#5519) --- lib/ansible/modules/cloud/docker/docker_container.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index a1a595ed2b..4bea65b5e6 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1201,6 +1201,12 @@ class Container(DockerBaseClass): # assuming if the container was running, it must have been detached. detach = not (config.get('AttachStderr') and config.get('AttachStdout')) + # "ExposedPorts": null returns None type & causes AttributeError - PR #5517 + if config.get('ExposedPorts') is not None: + expected_exposed = [re.sub(r'/.+$', '', p) for p in config.get('ExposedPorts', dict()).keys()] + else: + expected_exposed = [] + # Map parameters to container inspect results config_mapping = dict( image=config.get('Image'), @@ -1217,7 +1223,7 @@ class Container(DockerBaseClass): expected_env=(config.get('Env') or []), expected_entrypoint=config.get('Entrypoint'), expected_etc_hosts=host_config['ExtraHosts'], - expected_exposed=[re.sub(r'/.+$', '', p) for p in config.get('ExposedPorts', dict()).keys()], + expected_exposed=expected_exposed, groups=host_config.get('GroupAdd'), ipc_mode=host_config.get("IpcMode"), labels=config.get('Labels'),