2018-11-01 23:59:16 +01:00
|
|
|
---
|
|
|
|
- name: Registering network names
|
|
|
|
set_fact:
|
|
|
|
nname_ipam_0: "{{ name_prefix ~ '-network-ipam-0' }}"
|
|
|
|
nname_ipam_1: "{{ name_prefix ~ '-network-ipam-1' }}"
|
|
|
|
nname_ipam_2: "{{ name_prefix ~ '-network-ipam-2' }}"
|
|
|
|
nname_ipam_3: "{{ name_prefix ~ '-network-ipam-3' }}"
|
|
|
|
|
|
|
|
- name: Registering network names
|
|
|
|
set_fact:
|
2019-05-31 23:47:53 +02:00
|
|
|
dnetworks: "{{ dnetworks + [nname_ipam_0, nname_ipam_1, nname_ipam_2, nname_ipam_3] }}"
|
2018-11-01 23:59:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
#################### network-ipam-0 deprecated ####################
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Create network with ipam_config and deprecated ipam_options (conflicting)
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
ipam_options:
|
|
|
|
subnet: 172.3.29.0/24
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.3.29.0/24
|
|
|
|
register: network
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is failed
|
2019-03-15 02:29:55 +01:00
|
|
|
- "network.msg == 'parameters are mutually exclusive: ipam_config|ipam_options'"
|
2018-11-01 23:59:16 +01:00
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Create network with deprecated custom IPAM options
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
ipam_options:
|
|
|
|
subnet: 172.3.29.0/24
|
2019-05-26 22:41:06 +02:00
|
|
|
gateway: 172.3.29.2
|
|
|
|
iprange: 172.3.29.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.29.3
|
|
|
|
host2: 172.3.29.4
|
2018-11-01 23:59:16 +01:00
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Create network with deprecated custom IPAM options (idempotence)
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
ipam_options:
|
2019-05-26 22:41:06 +02:00
|
|
|
subnet: 172.3.29.0/24
|
|
|
|
gateway: 172.3.29.2
|
|
|
|
iprange: 172.3.29.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.29.3
|
|
|
|
host2: 172.3.29.4
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
|
|
|
|
|
|
|
- name: Change of network created with deprecated custom IPAM options
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
ipam_options:
|
|
|
|
subnet: 172.3.28.0/24
|
|
|
|
gateway: 172.3.28.2
|
|
|
|
iprange: 172.3.28.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.28.3
|
2018-11-01 23:59:16 +01:00
|
|
|
register: network
|
|
|
|
diff: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
2019-05-26 22:41:06 +02:00
|
|
|
- network.diff.differences | length == 4
|
|
|
|
- '"ipam_config[0].subnet" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].gateway" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].iprange" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].aux_addresses" in network.diff.differences'
|
|
|
|
|
|
|
|
- name: Remove gateway and iprange of network with deprecated custom IPAM options
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
ipam_options:
|
|
|
|
subnet: 172.3.28.0/24
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
2018-11-01 23:59:16 +01:00
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Cleanup network with deprecated custom IPAM options
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_0 }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
#################### network-ipam-1 ####################
|
|
|
|
- name: Create network with custom IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_1 }}"
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.3.27.0/24
|
|
|
|
gateway: 172.3.27.2
|
|
|
|
iprange: 172.3.27.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.27.3
|
|
|
|
host2: 172.3.27.4
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Create network with custom IPAM config (idempotence)
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_1 }}"
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.3.27.0/24
|
|
|
|
gateway: 172.3.27.2
|
|
|
|
iprange: 172.3.27.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.27.3
|
|
|
|
host2: 172.3.27.4
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
|
|
|
|
|
|
|
- name: Change of network created with custom IPAM config
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_1 }}"
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.3.28.0/24
|
|
|
|
gateway: 172.3.28.2
|
|
|
|
iprange: 172.3.28.0/26
|
|
|
|
aux_addresses:
|
|
|
|
host1: 172.3.28.3
|
|
|
|
register: network
|
|
|
|
diff: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
2018-11-19 10:59:54 +01:00
|
|
|
- network.diff.differences | length == 4
|
|
|
|
- '"ipam_config[0].subnet" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].gateway" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].iprange" in network.diff.differences'
|
|
|
|
- '"ipam_config[0].aux_addresses" in network.diff.differences'
|
2018-11-01 23:59:16 +01:00
|
|
|
|
|
|
|
- name: Remove gateway and iprange of network with custom IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_1 }}"
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.3.28.0/24
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
|
|
|
|
|
|
|
- name: Cleanup network with custom IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_1 }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
#################### network-ipam-2 ####################
|
|
|
|
|
|
|
|
- name: Create network with IPv6 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_2 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: fdd1:ac8c:0557:7ce0::/64
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Create network with IPv6 IPAM config (idempotence)
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_2 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: fdd1:ac8c:0557:7ce0::/64
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
|
|
|
|
2018-11-01 23:59:16 +01:00
|
|
|
- name: Change subnet of network with IPv6 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_2 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: fdd1:ac8c:0557:7ce1::/64
|
|
|
|
register: network
|
|
|
|
diff: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
2018-11-19 10:59:54 +01:00
|
|
|
- network.diff.differences | length == 1
|
|
|
|
- network.diff.differences[0] == "ipam_config[0].subnet"
|
2018-11-01 23:59:16 +01:00
|
|
|
|
|
|
|
- name: Change subnet of network with IPv6 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_2 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: "fdd1:ac8c:0557:7ce1::"
|
|
|
|
register: network
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is failed
|
|
|
|
- "network.msg == '\"fdd1:ac8c:0557:7ce1::\" is not a valid CIDR'"
|
|
|
|
|
|
|
|
- name: Cleanup network with IPv6 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_2 }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
#################### network-ipam-3 ####################
|
|
|
|
|
|
|
|
- name: Create network with IPv6 and custom IPv4 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.4.27.0/24
|
|
|
|
- subnet: fdd1:ac8c:0557:7ce2::/64
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Change subnet order of network with IPv6 and custom IPv4 IPAM config (idempotence)
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
enable_ipv6: yes
|
|
|
|
ipam_config:
|
|
|
|
- subnet: fdd1:ac8c:0557:7ce2::/64
|
|
|
|
- subnet: 172.4.27.0/24
|
|
|
|
register: network
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is not changed
|
|
|
|
|
2019-05-26 22:41:06 +02:00
|
|
|
- name: Remove IPv6 from network with custom IPv4 and IPv6 IPAM config (change)
|
2018-11-01 23:59:16 +01:00
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
enable_ipv6: no
|
|
|
|
ipam_config:
|
|
|
|
- subnet: 172.4.27.0/24
|
|
|
|
register: network
|
|
|
|
diff: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network is changed
|
2018-11-19 10:59:54 +01:00
|
|
|
- network.diff.differences | length == 1
|
|
|
|
- network.diff.differences[0] == "enable_ipv6"
|
2018-11-01 23:59:16 +01:00
|
|
|
|
|
|
|
- name: Cleanup network with IPv6 and custom IPv4 IPAM config
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
state: absent
|
2019-04-04 21:44:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
#################### network-ipam-4 ####################
|
|
|
|
|
|
|
|
- name: Create network with IPAM driver options
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
ipam_driver: default
|
|
|
|
ipam_driver_options:
|
|
|
|
a: b
|
|
|
|
register: network_1
|
2019-04-17 19:50:57 +02:00
|
|
|
ignore_errors: yes
|
2019-04-04 21:44:31 +02:00
|
|
|
- name: Create network with IPAM driver options (idempotence)
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
ipam_driver: default
|
|
|
|
ipam_driver_options:
|
|
|
|
a: b
|
|
|
|
diff: yes
|
|
|
|
register: network_2
|
2019-04-17 19:50:57 +02:00
|
|
|
ignore_errors: yes
|
2019-04-04 21:44:31 +02:00
|
|
|
- name: Create network with IPAM driver options (change)
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
ipam_driver: default
|
|
|
|
ipam_driver_options:
|
|
|
|
a: c
|
|
|
|
diff: yes
|
|
|
|
register: network_3
|
2019-04-17 19:50:57 +02:00
|
|
|
ignore_errors: yes
|
2019-04-04 21:44:31 +02:00
|
|
|
- name: Cleanup network
|
|
|
|
docker_network:
|
|
|
|
name: "{{ nname_ipam_3 }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network_1 is changed
|
|
|
|
- network_2 is not changed
|
|
|
|
- network_3 is changed
|
2019-04-17 19:50:57 +02:00
|
|
|
when: docker_py_version is version('2.0.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.0.0') in network_1.msg"
|
|
|
|
when: docker_py_version is version('2.0.0', '<')
|