Merge "Updated allocation pool checks"
This commit is contained in:
commit
1906b85668
@ -41,3 +41,6 @@
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Subnet Allocation
|
||||
include_tasks: subnet-allocation.yml
|
||||
|
63
ci/roles/subnet/tasks/subnet-allocation.yml
Normal file
63
ci/roles/subnet/tasks/subnet-allocation.yml
Normal file
@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Create network {{ network_name }}
|
||||
openstack.cloud.os_network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name }}"
|
||||
state: present
|
||||
|
||||
- name: Create subnet {{ subnet_name }} on network {{ network_name }}
|
||||
openstack.cloud.os_subnet:
|
||||
cloud: "{{ cloud }}"
|
||||
network_name: "{{ network_name }}"
|
||||
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||
name: "{{ subnet_name }}"
|
||||
state: present
|
||||
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.4
|
||||
|
||||
- name: Update subnet {{ subnet_name }} allocation pools
|
||||
openstack.cloud.os_subnet:
|
||||
cloud: "{{ cloud }}"
|
||||
network_name: "{{ network_name }}"
|
||||
name: "{{ subnet_name }}"
|
||||
state: present
|
||||
cidr: 192.168.0.0/24
|
||||
allocation_pool_start: 192.168.0.5
|
||||
allocation_pool_end: 192.168.0.8
|
||||
|
||||
- name: Get Subnet Info
|
||||
openstack.cloud.os_subnets_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ subnet_name }}"
|
||||
register: subnet_result
|
||||
|
||||
- name: Verify Subnet Allocation Pools Exist
|
||||
assert:
|
||||
that:
|
||||
- subnet_result.openstack_subnets is defined
|
||||
- subnet_result.openstack_subnets | length == 1
|
||||
- subnet_result.openstack_subnets[0].allocation_pools is defined
|
||||
- subnet_result.openstack_subnets[0].allocation_pools | length == 2
|
||||
|
||||
- name: Verify Subnet Allocation Pools
|
||||
assert:
|
||||
that:
|
||||
- subnet_result.openstack_subnets[0].allocation_pools | selectattr('start','equalto',item.start) | list | count > 0
|
||||
- subnet_result.openstack_subnets[0].allocation_pools | selectattr('end','equalto',item.end) | list | count > 0
|
||||
loop:
|
||||
- {start: '192.168.0.2', end: '192.168.0.4'}
|
||||
- {start: '192.168.0.5', end: '192.168.0.8'}
|
||||
|
||||
- name: Delete subnet {{ subnet_name }}
|
||||
openstack.cloud.os_subnet:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ subnet_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete network {{ network_name }}
|
||||
openstack.cloud.os_network:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ network_name }}"
|
||||
state: absent
|
@ -205,15 +205,15 @@ def _needs_update(subnet, module, cloud, filters=None):
|
||||
no_gateway_ip = module.params['no_gateway_ip']
|
||||
dns = module.params['dns_nameservers']
|
||||
host_routes = module.params['host_routes']
|
||||
curr_pool = subnet['allocation_pools'][0]
|
||||
curr_pool = dict(start=pool_start, end=pool_end)
|
||||
|
||||
if subnet['enable_dhcp'] != enable_dhcp:
|
||||
return True
|
||||
if subnet_name and subnet['name'] != subnet_name:
|
||||
return True
|
||||
if pool_start and curr_pool['start'] != pool_start:
|
||||
if not subnet['allocation_pools'] and pool_start and pool_end:
|
||||
return True
|
||||
if pool_end and curr_pool['end'] != pool_end:
|
||||
if subnet['allocation_pools'] and curr_pool not in subnet['allocation_pools']:
|
||||
return True
|
||||
if gateway_ip and subnet['gateway_ip'] != gateway_ip:
|
||||
return True
|
||||
@ -352,6 +352,8 @@ def main():
|
||||
changed = True
|
||||
else:
|
||||
if _needs_update(subnet, module, cloud, filters):
|
||||
if subnet['allocation_pools'] and pool is not None:
|
||||
pool = pool + subnet['allocation_pools']
|
||||
cloud.update_subnet(subnet['id'],
|
||||
subnet_name=subnet_name,
|
||||
enable_dhcp=enable_dhcp,
|
||||
|
Loading…
x
Reference in New Issue
Block a user