mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
[docker_network] Adding scope
and attachable
flags (#49562)
Incorporating the abandoned work from PRs #35288 and #45552. Also adding in the version checking from `docker_container.py`, which should be abstracted out to `docker_common.py`.
This commit is contained in:
parent
4f9f1754b4
commit
73640a4190
6 changed files with 206 additions and 15 deletions
|
@ -92,3 +92,100 @@
|
|||
- driver_options_3 is not changed
|
||||
- driver_options_4 is changed
|
||||
- driver_options_5 is not changed
|
||||
|
||||
####################################################################
|
||||
## scope ###########################################################
|
||||
####################################################################
|
||||
|
||||
- block:
|
||||
- name: scope
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
driver: bridge
|
||||
scope: local
|
||||
register: scope_1
|
||||
|
||||
- name: scope (idempotency)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
driver: bridge
|
||||
scope: local
|
||||
register: scope_2
|
||||
|
||||
- name: swarm
|
||||
docker_swarm:
|
||||
state: present
|
||||
advertise_addr: "{{ansible_default_ipv4.address}}"
|
||||
|
||||
# Driver change alongside scope is intentional - bridge doesn't appear to support anything but local, and overlay can't downgrade to local. Additionally, overlay reports as swarm for swarm OR global, so no change is reported in that case.
|
||||
# Test output indicates that the scope is altered, at least, so manual inspection will be required to verify this going forward, unless we come up with a test driver that supports multiple scopes.
|
||||
- name: scope (change)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
driver: overlay
|
||||
scope: swarm
|
||||
register: scope_3
|
||||
|
||||
- name: cleanup network
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- scope_1 is changed
|
||||
- scope_2 is not changed
|
||||
- scope_3 is changed
|
||||
|
||||
always:
|
||||
- name: cleanup swarm
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
# Requirements for docker_swarm
|
||||
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.35', '>=')
|
||||
|
||||
####################################################################
|
||||
## attachable ######################################################
|
||||
####################################################################
|
||||
|
||||
- name: attachable
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
attachable: true
|
||||
register: attachable_1
|
||||
ignore_errors: yes
|
||||
|
||||
- name: attachable (idempotency)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
attachable: true
|
||||
register: attachable_2
|
||||
ignore_errors: yes
|
||||
|
||||
- name: attachable (change)
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
attachable: false
|
||||
register: attachable_3
|
||||
ignore_errors: yes
|
||||
|
||||
- name: cleanup
|
||||
docker_network:
|
||||
name: "{{ nname_1 }}"
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- attachable_1 is changed
|
||||
- attachable_2 is not changed
|
||||
- attachable_3 is changed
|
||||
when: docker_py_version is version('2.0.0', '>=')
|
||||
- assert:
|
||||
that:
|
||||
- attachable_1 is failed
|
||||
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.0.0') in attachable_1.msg"
|
||||
when: docker_py_version is version('2.0.0', '<')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue