Files
ansible-collections-openstack/ci/roles/subnet/tasks/main.yml
George Shuklin e0139fe940 fix: subnet module: allow cidr option with subnet_pool
Specifying CIDR during creation of subnet from subnet pool is a valid
operation. Moreover, in case of use of a subnet pool with multiple
subnets, cidr is a mandatory paramter for creating subnet.

Following code should be valid:

    - name: Create subnet
      openstack.cloud.subnet:
        name: "subnet_name"
        network: "some_network"
        gateway_ip: "192.168.0.1"
        allocation_pool_start: "192.168.0.2"
        allocation_pool_end: "192.168.0.254"
        cidr: "192.168.0.0/24"
        ip_version: 4
        subnet_pool: "192.168.0.0/24"

This scenario is added as a subnet-pool.yaml test in the test role.

Change-Id: I1163ba34ac3079f76dd0b7477a80a2135985a650
2024-04-05 12:30:22 +03:00

156 lines
3.6 KiB
YAML

---
- name: Delete subnet {{ subnet_name }} before test
openstack.cloud.subnet:
cloud: "{{ cloud }}"
name: "{{ subnet_name }}"
state: absent
- name: Delete network {{ network_name }} before test
openstack.cloud.network:
cloud: "{{ cloud }}"
name: "{{ network_name }}"
state: absent
- name: Create network {{ network_name }}
openstack.cloud.network:
cloud: "{{ cloud }}"
name: "{{ network_name }}"
state: present
- name: Create subnet {{ subnet_name }} on network {{ network_name }}
openstack.cloud.subnet:
cloud: "{{ cloud }}"
network_name: "{{ network_name }}"
name: "{{ subnet_name }}"
state: present
enable_dhcp: "{{ enable_subnet_dhcp }}"
dns_nameservers:
- 8.8.8.7
- 8.8.8.8
cidr: 192.168.0.0/24
gateway_ip: 192.168.0.1
allocation_pool_start: 192.168.0.2
allocation_pool_end: 192.168.0.254
register: subnet
- name: Assert changed
assert:
that: subnet is changed
- name: assert subnet fields
assert:
that: item in subnet.subnet
loop: "{{ expected_fields }}"
- name: Create subnet {{ subnet_name }} on network {{ network_name }} again
openstack.cloud.subnet:
cloud: "{{ cloud }}"
network_name: "{{ network_name }}"
name: "{{ subnet_name }}"
state: present
enable_dhcp: "{{ enable_subnet_dhcp }}"
dns_nameservers:
- 8.8.8.7
- 8.8.8.8
cidr: 192.168.0.0/24
gateway_ip: 192.168.0.1
allocation_pool_start: 192.168.0.2
allocation_pool_end: 192.168.0.254
register: subnet
- name: Assert not changed
assert:
that: subnet is not changed
- name: Get Subnet Info with name
openstack.cloud.subnets_info:
cloud: "{{ cloud }}"
name: "{{ subnet_name }}"
register: subnet
- name: assert subnet fields
assert:
that: item in subnet.subnets[0]
loop: "{{ expected_fields }}"
- name: Get Subnet Info with filters
openstack.cloud.subnets_info:
cloud: "{{ cloud }}"
filters:
enable_dhcp: "{{ enable_subnet_dhcp }}"
gateway_ip: 192.168.0.1
cidr: 192.168.0.0/24
register: subnet
- name: Verify Subnet info result
assert:
that:
- subnet is not changed
- subnet.subnets is defined
- subnet.subnets | length > 0
- name: Get Subnet Info with name and improper filter values
openstack.cloud.subnets_info:
cloud: "{{ cloud }}"
name: "{{ subnet_name }}"
filters:
gateway_ip: 192.168.16.1
cidr: 192.168.16.0/24
register: subnet
- name: Verify Subnet info result
assert:
that:
- subnet is not changed
- subnet.subnets is defined
- subnet.subnets | length == 0
- name: Update subnet
openstack.cloud.subnet:
cloud: "{{ cloud }}"
network_name: "{{ network_name }}"
name: "{{ subnet_name }}"
state: present
dns_nameservers:
- 8.8.8.7
cidr: 192.168.0.0/24
register: subnet
- name: Assert changed
assert:
that: subnet is changed
- name: Delete subnet {{ subnet_name }}
openstack.cloud.subnet:
cloud: "{{ cloud }}"
name: "{{ subnet_name }}"
state: absent
register: subnet
- name: Assert changed
assert:
that: subnet is changed
- name: Delete subnet {{ subnet_name }} again
openstack.cloud.subnet:
cloud: "{{ cloud }}"
name: "{{ subnet_name }}"
state: absent
register: subnet
- name: Assert not changed
assert:
that: subnet is not changed
- name: Delete network {{ network_name }}
openstack.cloud.network:
cloud: "{{ cloud }}"
name: "{{ network_name }}"
state: absent
- name: Subnet Allocation
include_tasks: subnet-allocation.yml
- name: Subnet Allocations from Subnet Pool
include_tasks: subnet-pool.yaml