mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
43a44e6f35
Move the following methods to lib/anisble/module_utils/common/validation.py: - _count_terms() - _check_mutually_exclusive() - _check_required_one_of() - _check_required_together() - _check_required_by() - _check_required_arguments() - _check_required_if - fail_on_missing_params() --> create check_missing_parameters()
212 lines
5.2 KiB
YAML
212 lines
5.2 KiB
YAML
---
|
|
- 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:
|
|
dnetworks: "{{ dnetworks }} + [nname_ipam_0, nname_ipam_1, nname_ipam_2, nname_ipam_3]"
|
|
|
|
|
|
#################### network-ipam-0 deprecated ####################
|
|
|
|
- name: Create network with ipam_config and deprecated ipam_options
|
|
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
|
|
- "network.msg == 'parameters are mutually exclusive: ipam_config|ipam_options'"
|
|
|
|
- name: Create network with deprecated custom IPAM config
|
|
docker_network:
|
|
name: "{{ nname_ipam_0 }}"
|
|
ipam_options:
|
|
subnet: 172.3.29.0/24
|
|
register: network
|
|
|
|
- assert:
|
|
that:
|
|
- network is changed
|
|
|
|
- name: Change subnet of network with deprecated custom IPAM config
|
|
docker_network:
|
|
name: "{{ nname_ipam_0 }}"
|
|
ipam_options:
|
|
subnet: 172.3.30.0/24
|
|
register: network
|
|
diff: yes
|
|
|
|
- assert:
|
|
that:
|
|
- network is changed
|
|
- network.diff.differences | length == 1
|
|
- network.diff.differences[0] == "ipam_config[0].subnet"
|
|
|
|
- name: Cleanup network with ipam_config and deprecated ipam_options
|
|
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
|
|
|
|
- name: Change subnet, gateway, iprange and auxiliary addresses of network with custom IPAM config
|
|
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
|
|
- 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 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
|
|
|
|
- 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
|
|
- network.diff.differences | length == 1
|
|
- network.diff.differences[0] == "ipam_config[0].subnet"
|
|
|
|
- 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
|
|
|
|
- name: Change subnet order of network with IPv6 and custom IPv4 IPAM config
|
|
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
|
|
|
|
- name: Remove IPv6 from network with custom IPv4 and IPv6 IPAM config
|
|
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
|
|
- network.diff.differences | length == 1
|
|
- network.diff.differences[0] == "enable_ipv6"
|
|
|
|
- name: Cleanup network with IPv6 and custom IPv4 IPAM config
|
|
docker_network:
|
|
name: "{{ nname_ipam_3 }}"
|
|
state: absent
|