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 00000000000..9dec54391ba --- /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 358195c868d..d266fdc69c5 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1223,7 +1223,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' @@ -2130,6 +2130,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient): comparisons['image']['comparison'] = 'ignore' # 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') self.comparisons = comparisons def __init__(self, **kwargs):