From 1277942a4e5d479e73cd33c7ac24c27c418d6a90 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 26 Dec 2020 18:20:52 +0100 Subject: [PATCH] Deprecate current behavior when specifying all with other port mappings. (#60) --- .../fragments/60-docker_container-publish-all.yml | 2 ++ plugins/modules/docker_container.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/60-docker_container-publish-all.yml diff --git a/changelogs/fragments/60-docker_container-publish-all.yml b/changelogs/fragments/60-docker_container-publish-all.yml new file mode 100644 index 000000000..e9e476810 --- /dev/null +++ b/changelogs/fragments/60-docker_container-publish-all.yml @@ -0,0 +1,2 @@ +deprecated_features: +- "docker_container - currently ``published_ports`` can contain port mappings next to the special value ``all``, in which case the port mappings are ignored. This behavior is deprecated for community.docker 2.0.0, at which point it will either be forbidden, or this behavior will be properly implemented similar to how the Docker CLI tool handles this (https://github.com/ansible-collections/community.docker/issues/8, https://github.com/ansible-collections/community.docker/pull/60)." diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index f9e42f2e5..c1dc68a2d 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -1366,7 +1366,7 @@ def __init__(self, client): self.publish_all_ports = False self.published_ports = self._parse_publish_ports() - if self.published_ports in ('all', 'ALL'): + if self.published_ports == 'all': self.publish_all_ports = True self.published_ports = None @@ -1684,6 +1684,14 @@ def _parse_publish_ports(self): return None if 'all' in self.published_ports: + if len(self.published_ports) > 1: + self.client.module.deprecate( + 'Specifying "all" in published_ports together with port mappings is not properly ' + 'supported by the module. The port mappings are currently ignored. Please specify ' + 'only port mappings, or the value "all". The behavior for mixed usage will either ' + 'be forbidden in version 2.0.0, or properly handled. In any case, the way you ' + 'currently use the module will change in a breaking way', + collection_name='community.docker', version='2.0.0') return 'all' default_ip = self.default_host_ip