From c5ea3d058e1f4525f1a1dd4a9756cdb3c59695a8 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 8 Oct 2018 09:41:15 +0200 Subject: [PATCH] docker_container: fix problem with published_ports idempotency (#46595) * Fix comparisons for expected_ports (set vs dict). * Added changelog. --- changelogs/fragments/46595-docker_container-expected_ports.yml | 2 ++ lib/ansible/modules/cloud/docker/docker_container.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/46595-docker_container-expected_ports.yml diff --git a/changelogs/fragments/46595-docker_container-expected_ports.yml b/changelogs/fragments/46595-docker_container-expected_ports.yml new file mode 100644 index 0000000000..9dec54391b --- /dev/null +++ b/changelogs/fragments/46595-docker_container-expected_ports.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_container - fix idempotency check for published_ports in some special cases." diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index ae70076353..5840de4793 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1314,7 +1314,7 @@ class Container(DockerBaseClass): self.parameters.expected_env = None self.parameters_map = dict() self.parameters_map['expected_links'] = 'links' - self.parameters_map['expected_ports'] = 'published_ports' + self.parameters_map['expected_ports'] = 'expected_ports' self.parameters_map['expected_exposed'] = 'exposed_ports' self.parameters_map['expected_volumes'] = 'volumes' self.parameters_map['expected_ulimits'] = 'ulimits' @@ -2294,6 +2294,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient): self.fail("Unknown comparison mode '%s'!" % value) # Add implicit options comparisons['publish_all_ports'] = dict(type='value', comparison='strict', name='published_ports') + comparisons['expected_ports'] = dict(type='dict', comparison=comparisons['published_ports']['comparison'], name='expected_ports') # Check legacy values if self.module.params['ignore_image'] and comparisons['image']['comparison'] != 'ignore': self.module.warn('The ignore_image option has been overridden by the comparisons option!')