mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[docker_container] Fixes idempotency checks for network_mode (#49797)
Fixes #49794
This commit is contained in:
parent
d36922064b
commit
8fcf9e1a28
3 changed files with 37 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- docker_container - fix ``network_mode`` idempotency if the ``container:<container-name>`` form is used (as opposed to ``container:<container-id>``) (https://github.com/ansible/ansible/issues/49794)
|
|
@ -1090,6 +1090,7 @@ class TaskParameters(DockerBaseClass):
|
|||
self.volume_binds = self._get_volume_binds(self.volumes)
|
||||
self.pid_mode = self._replace_container_names(self.pid_mode)
|
||||
self.ipc_mode = self._replace_container_names(self.ipc_mode)
|
||||
self.network_mode = self._replace_container_names(self.network_mode)
|
||||
|
||||
self.log("volumes:")
|
||||
self.log(self.volumes, pretty_print=True)
|
||||
|
|
|
@ -2440,11 +2440,42 @@
|
|||
force_kill: yes
|
||||
register: network_mode_3
|
||||
|
||||
- name: network_mode (container mode setup)
|
||||
docker_container:
|
||||
image: alpine:3.8
|
||||
command: '/bin/sh -c "sleep 10m"'
|
||||
name: "{{ cname_h1 }}"
|
||||
state: started
|
||||
|
||||
- name: network_mode (container mode)
|
||||
docker_container:
|
||||
image: alpine:3.8
|
||||
command: '/bin/sh -c "sleep 10m"'
|
||||
name: "{{ cname }}"
|
||||
state: started
|
||||
network_mode: "container:{{ cname_h1 }}"
|
||||
force_kill: yes
|
||||
register: network_mode_4
|
||||
|
||||
- name: network_mode (container mode idempotency)
|
||||
docker_container:
|
||||
image: alpine:3.8
|
||||
command: '/bin/sh -c "sleep 10m"'
|
||||
name: "{{ cname }}"
|
||||
state: started
|
||||
network_mode: "container:{{ cname_h1 }}"
|
||||
register: network_mode_5
|
||||
|
||||
- name: cleanup
|
||||
docker_container:
|
||||
name: "{{ cname }}"
|
||||
name: "{{ container_name }}"
|
||||
state: absent
|
||||
force_kill: yes
|
||||
loop:
|
||||
- "{{ cname }}"
|
||||
- "{{ cname_h1 }}"
|
||||
loop_control:
|
||||
loop_var: container_name
|
||||
diff: no
|
||||
|
||||
- assert:
|
||||
|
@ -2452,6 +2483,8 @@
|
|||
- network_mode_1 is changed
|
||||
- network_mode_2 is not changed
|
||||
- network_mode_3 is changed
|
||||
- network_mode_4 is changed
|
||||
- network_mode_5 is not changed
|
||||
|
||||
####################################################################
|
||||
## networks, purge_networks ########################################
|
||||
|
|
Loading…
Reference in a new issue