docker_container: improve publish all ports functionality (#46594)

* Improve handling of published_ports: all.

* Add changelog.

(cherry picked from commit 8afe46dc02)
pull/47145/head
Felix Fontein 6 years ago committed by Matt Clay
parent fac1405bcc
commit 05c6df53f0

@ -0,0 +1,2 @@
bugfixes:
- "docker_container - ``publish_ports: all`` was not used correctly when checking idempotency."

@ -267,7 +267,7 @@ options:
- "Use docker CLI syntax: C(8000), C(9000:8000), or C(0.0.0.0:9000:8000), where 8000 is a
container port, 9000 is a host port, and 0.0.0.0 is a host interface."
- Container ports must be exposed either in the Dockerfile or via the C(expose) option.
- A value of all will publish all exposed container ports to random host ports, ignoring
- A value of C(all) will publish all exposed container ports to random host ports, ignoring
any other mappings.
- If C(networks) parameter is provided, will inspect each network to see if there exists
a bridge network with optional parameter com.docker.network.bridge.host_binding_ipv4.
@ -1408,7 +1408,8 @@ class Container(DockerBaseClass):
expected_volumes=config.get('Volumes'),
expected_binds=host_config.get('Binds'),
volumes_from=host_config.get('VolumesFrom'),
working_dir=config.get('WorkingDir')
working_dir=config.get('WorkingDir'),
publish_all_ports=host_config.get('PublishAllPorts'),
)
if self.parameters.restart_policy:
config_mapping['restart_retries'] = restart_policy.get('MaximumRetryCount')
@ -2127,6 +2128,8 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
# Process legacy ignore options
if self.module.params['ignore_image']:
comparisons['image']['comparison'] = 'ignore'
# Add implicit options
comparisons['publish_all_ports'] = dict(type='value', comparison='strict', name='published_ports')
self.comparisons = comparisons
def __init__(self, **kwargs):

Loading…
Cancel
Save