mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 04:18:42 +00:00
Remove deprecations from docker_container, bump collection version to 3.0.0 (#399)
* Remove deprecated features in docker_container. * Bump collection version to 3.0.0. * Remove 'published_ports: all' tests.
This commit is contained in:
parent
209aeb57fd
commit
49ce0a3cb1
3
changelogs/fragments/399-deprecations.yml
Normal file
3
changelogs/fragments/399-deprecations.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
removed_features:
|
||||||
|
- "docker_container - the default of ``command_handling`` was changed from ``compatibility`` to ``correct``. Older versions were warning for every invocation of the module when this would result in a change of behavior (https://github.com/ansible-collections/community.docker/pull/399)."
|
||||||
|
- "docker_container - the ``all`` value is no longer allowed in ``published_ports``. Use ``publish_all_ports=true`` instead (https://github.com/ansible-collections/community.docker/pull/399)."
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace: community
|
namespace: community
|
||||||
name: docker
|
name: docker
|
||||||
version: 2.7.0
|
version: 3.0.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Ansible Docker Working Group
|
- Ansible Docker Working Group
|
||||||
|
|||||||
@ -106,16 +106,17 @@ options:
|
|||||||
- Also, setting I(command) to an empty list of string, and setting I(entrypoint) to an empty
|
- Also, setting I(command) to an empty list of string, and setting I(entrypoint) to an empty
|
||||||
list will be handled as if these options are not specified. This is different from idempotency
|
list will be handled as if these options are not specified. This is different from idempotency
|
||||||
handling for other container-config related options.
|
handling for other container-config related options.
|
||||||
- When this is set to C(compatibility), which is the default until community.docker 3.0.0, the
|
- When this is set to C(compatibility), which was the default until community.docker 3.0.0, the
|
||||||
current behavior will be kept.
|
current behavior will be kept.
|
||||||
- When this is set to C(correct), these options are kept as lists, and an empty value or empty
|
- When this is set to C(correct), these options are kept as lists, and an empty value or empty
|
||||||
list will be handled correctly for idempotency checks.
|
list will be handled correctly for idempotency checks. This has been the default since
|
||||||
- In community.docker 3.0.0, the default will change to C(correct).
|
community.docker 3.0.0.
|
||||||
type: str
|
type: str
|
||||||
choices:
|
choices:
|
||||||
- compatibility
|
- compatibility
|
||||||
- correct
|
- correct
|
||||||
version_added: 1.9.0
|
version_added: 1.9.0
|
||||||
|
default: correct
|
||||||
cpu_period:
|
cpu_period:
|
||||||
description:
|
description:
|
||||||
- Limit CPU CFS (Completely Fair Scheduler) period.
|
- Limit CPU CFS (Completely Fair Scheduler) period.
|
||||||
@ -702,15 +703,14 @@ options:
|
|||||||
- "Bind addresses must be either IPv4 or IPv6 addresses. Hostnames are B(not) allowed. This
|
- "Bind addresses must be either IPv4 or IPv6 addresses. Hostnames are B(not) allowed. This
|
||||||
is different from the C(docker) command line utility. Use the R(dig lookup,ansible_collections.community.general.dig_lookup)
|
is different from the C(docker) command line utility. Use the R(dig lookup,ansible_collections.community.general.dig_lookup)
|
||||||
to resolve hostnames."
|
to resolve hostnames."
|
||||||
- A value of C(all) will publish all exposed container ports to random host ports, ignoring
|
|
||||||
any other mappings. This is deprecated since version 2.0.0 and will be disallowed in
|
|
||||||
community.docker 3.0.0. Use the I(publish_all_ports) option instead.
|
|
||||||
- If I(networks) parameter is provided, will inspect each network to see if there exists
|
- If I(networks) parameter is provided, will inspect each network to see if there exists
|
||||||
a bridge network with optional parameter C(com.docker.network.bridge.host_binding_ipv4).
|
a bridge network with optional parameter C(com.docker.network.bridge.host_binding_ipv4).
|
||||||
If such a network is found, then published ports where no host IP address is specified
|
If such a network is found, then published ports where no host IP address is specified
|
||||||
will be bound to the host IP pointed to by C(com.docker.network.bridge.host_binding_ipv4).
|
will be bound to the host IP pointed to by C(com.docker.network.bridge.host_binding_ipv4).
|
||||||
Note that the first bridge network with a C(com.docker.network.bridge.host_binding_ipv4)
|
Note that the first bridge network with a C(com.docker.network.bridge.host_binding_ipv4)
|
||||||
value encountered in the list of I(networks) is the one that will be used.
|
value encountered in the list of I(networks) is the one that will be used.
|
||||||
|
- The value C(all) was allowed in earlier versions of this module. Support for it was removed in
|
||||||
|
community.docker 3.0.0. Use the I(publish_all_ports) option instead.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
aliases:
|
aliases:
|
||||||
@ -1452,13 +1452,6 @@ class TaskParameters(DockerBaseClass):
|
|||||||
|
|
||||||
self.published_ports = self._parse_publish_ports()
|
self.published_ports = self._parse_publish_ports()
|
||||||
|
|
||||||
if self.published_ports == 'all':
|
|
||||||
if self.publish_all_ports is None:
|
|
||||||
self.publish_all_ports = True
|
|
||||||
self.published_ports = None
|
|
||||||
else:
|
|
||||||
self.fail('"all" is not a valid value for "published_ports" when "publish_all_ports" is specified')
|
|
||||||
|
|
||||||
self.ports = self._parse_exposed_ports(self.published_ports)
|
self.ports = self._parse_exposed_ports(self.published_ports)
|
||||||
self.log("expose ports:")
|
self.log("expose ports:")
|
||||||
self.log(self.ports, pretty_print=True)
|
self.log(self.ports, pretty_print=True)
|
||||||
@ -1511,37 +1504,18 @@ class TaskParameters(DockerBaseClass):
|
|||||||
self.command = shlex.split(to_text(self.command, errors='surrogate_or_strict'))
|
self.command = shlex.split(to_text(self.command, errors='surrogate_or_strict'))
|
||||||
self.command = [to_text(x, errors='surrogate_or_strict') for x in self.command]
|
self.command = [to_text(x, errors='surrogate_or_strict') for x in self.command]
|
||||||
else:
|
else:
|
||||||
will_change = False
|
|
||||||
if self.entrypoint:
|
if self.entrypoint:
|
||||||
# convert from list to str.
|
# convert from list to str.
|
||||||
correct_entrypoint = [to_text(x, errors='surrogate_or_strict') for x in self.entrypoint]
|
|
||||||
self.entrypoint = shlex.split(' '.join([to_text(x, errors='surrogate_or_strict') for x in self.entrypoint]))
|
self.entrypoint = shlex.split(' '.join([to_text(x, errors='surrogate_or_strict') for x in self.entrypoint]))
|
||||||
self.entrypoint = [to_text(x, errors='surrogate_or_strict') for x in self.entrypoint]
|
self.entrypoint = [to_text(x, errors='surrogate_or_strict') for x in self.entrypoint]
|
||||||
if correct_entrypoint != self.entrypoint:
|
|
||||||
will_change = True
|
|
||||||
elif self.entrypoint is not None:
|
|
||||||
will_change = True
|
|
||||||
|
|
||||||
if self.command:
|
if self.command:
|
||||||
# convert from list to str
|
# convert from list to str
|
||||||
if isinstance(self.command, list):
|
if isinstance(self.command, list):
|
||||||
correct_command = [to_text(x, errors='surrogate_or_strict') for x in self.command]
|
self.command = ' '.join([to_text(x, errors='surrogate_or_strict') for x in self.command])
|
||||||
self.command = shlex.split(' '.join([to_text(x, errors='surrogate_or_strict') for x in self.command]))
|
|
||||||
self.command = [to_text(x, errors='surrogate_or_strict') for x in self.command]
|
|
||||||
if correct_command != self.command:
|
|
||||||
will_change = True
|
|
||||||
else:
|
else:
|
||||||
self.command = shlex.split(to_text(self.command, errors='surrogate_or_strict'))
|
self.command = to_text(self.command, errors='surrogate_or_strict')
|
||||||
self.command = [to_text(x, errors='surrogate_or_strict') for x in self.command]
|
self.command = [to_text(x, errors='surrogate_or_strict') for x in shlex.split(self.command)]
|
||||||
elif self.command is not None:
|
|
||||||
will_change = True
|
|
||||||
|
|
||||||
if will_change and client.module.params['command_handling'] is None:
|
|
||||||
client.module.deprecate(
|
|
||||||
'The command_handling option will change its default value from "compatibility" to '
|
|
||||||
'"correct" in community.docker 3.0.0. To remove this warning, please specify an explicit value for it now',
|
|
||||||
version='3.0.0', collection_name='community.docker'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.mounts_opt, self.expected_mounts = self._process_mounts()
|
self.mounts_opt, self.expected_mounts = self._process_mounts()
|
||||||
|
|
||||||
@ -1809,15 +1783,9 @@ class TaskParameters(DockerBaseClass):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if 'all' in self.published_ports:
|
if 'all' in self.published_ports:
|
||||||
if len(self.published_ports) > 1:
|
self.client.module.fail_json(
|
||||||
self.client.module.fail_json(msg='"all" can no longer be specified in published_ports next to '
|
msg='Specifying "all" in published_ports is no longer allowed. Set publish_all_ports to "true" instead '
|
||||||
'other values. Set publish_all_ports to "true" to randomly '
|
'to randomly assign port mappings for those not specified by published_ports.')
|
||||||
'assign port mappings for those not specified by published_ports.')
|
|
||||||
self.client.module.deprecate(
|
|
||||||
'Specifying "all" in published_ports is deprecated. Set publish_all_ports to "true" instead '
|
|
||||||
'to randomly assign port mappings for those not specified by published_ports',
|
|
||||||
collection_name='community.docker', version='3.0.0')
|
|
||||||
return 'all'
|
|
||||||
|
|
||||||
default_ip = self.get_default_host_ip()
|
default_ip = self.get_default_host_ip()
|
||||||
|
|
||||||
@ -3553,7 +3521,7 @@ def main():
|
|||||||
command=dict(type='raw'),
|
command=dict(type='raw'),
|
||||||
comparisons=dict(type='dict'),
|
comparisons=dict(type='dict'),
|
||||||
container_default_behavior=dict(type='str', default='no_defaults', choices=['compatibility', 'no_defaults']),
|
container_default_behavior=dict(type='str', default='no_defaults', choices=['compatibility', 'no_defaults']),
|
||||||
command_handling=dict(type='str', choices=['compatibility', 'correct']),
|
command_handling=dict(type='str', choices=['compatibility', 'correct'], default='correct'),
|
||||||
cpu_period=dict(type='int'),
|
cpu_period=dict(type='int'),
|
||||||
cpu_quota=dict(type='int'),
|
cpu_quota=dict(type='int'),
|
||||||
cpus=dict(type='float'),
|
cpus=dict(type='float'),
|
||||||
|
|||||||
@ -53,111 +53,6 @@
|
|||||||
- published_ports_3 is failed
|
- published_ports_3 is failed
|
||||||
- "published_ports_3.msg == 'Bind addresses for published ports must be IPv4 or IPv6 addresses, not hostnames. Use the dig lookup to resolve hostnames. (Found hostname: foo)'"
|
- "published_ports_3.msg == 'Bind addresses for published ports must be IPv4 or IPv6 addresses, not hostnames. Use the dig lookup to resolve hostnames. (Found hostname: foo)'"
|
||||||
|
|
||||||
####################################################################
|
|
||||||
## published_ports: all ############################################
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
- name: published_ports -- all
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
published_ports:
|
|
||||||
- all
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_1
|
|
||||||
|
|
||||||
- name: published_ports -- all (idempotency)
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
published_ports:
|
|
||||||
- all
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_2
|
|
||||||
|
|
||||||
- name: published_ports -- all (writing out 'all')
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
published_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_3
|
|
||||||
|
|
||||||
- name: published_ports -- all (idempotency 2)
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
published_ports:
|
|
||||||
- "9002"
|
|
||||||
- "9001"
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_4
|
|
||||||
|
|
||||||
- name: published_ports -- all (switching back to 'all')
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
published_ports:
|
|
||||||
- all
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_5
|
|
||||||
|
|
||||||
- name: published_ports -- all equivalence with publish_all_ports
|
|
||||||
docker_container:
|
|
||||||
image: "{{ docker_test_image_alpine }}"
|
|
||||||
command: '/bin/sh -c "sleep 10m"'
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: started
|
|
||||||
exposed_ports:
|
|
||||||
- "9001"
|
|
||||||
- "9002"
|
|
||||||
publish_all_ports: true
|
|
||||||
force_kill: yes
|
|
||||||
register: published_ports_6
|
|
||||||
|
|
||||||
- name: cleanup
|
|
||||||
docker_container:
|
|
||||||
name: "{{ cname }}"
|
|
||||||
state: absent
|
|
||||||
force_kill: yes
|
|
||||||
diff: no
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- published_ports_1 is changed
|
|
||||||
- published_ports_2 is not changed
|
|
||||||
- published_ports_3 is changed
|
|
||||||
- published_ports_4 is not changed
|
|
||||||
- published_ports_5 is changed
|
|
||||||
- published_ports_6 is not changed
|
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## published_ports: port range #####################################
|
## published_ports: port range #####################################
|
||||||
####################################################################
|
####################################################################
|
||||||
@ -424,4 +319,4 @@
|
|||||||
loop: "{{ publish_all_ports_test_cases }}"
|
loop: "{{ publish_all_ports_test_cases }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
index_var: index
|
index_var: index
|
||||||
loop_var: test_case
|
loop_var: test_case
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user