-
Notifications
You must be signed in to change notification settings - Fork 10
/
sharednet.yml
70 lines (67 loc) · 2.56 KB
/
sharednet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
- name: Set fact for sharednet segmentation id
set_fact:
sharednet_segmentation_id: "{{ (shared_network.on_demand_vlan_ranges[0].split(':')[0] | int) + 1 }}"
when:
- shared_network.on_demand_vlan_ranges is defined
- shared_network.on_demand_vlan_ranges | length > 0
- name: Create shared network(s)
kolla_toolbox:
module_name: os_network
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
name: "{{ item.sharednet.name | default(default_sharednet_name) }}"
provider_network_type: "{{ item.network_type | default('vlan') }}"
# Use the first on-demand VLAN for this network.
provider_segmentation_id: "{{ sharednet_segmentation_id | default(omit) }}"
provider_physical_network: "{{ '' if (item.network_type | default('vlan')) == 'vxlan' else item.name }}"
shared: yes
state: present
loop: "{{ neutron_networks }}"
loop_control:
label: "{{ item.name }}"
become: true
run_once: True
when:
- item.sharednet is defined
- name: Create shared network subnet(s)
kolla_toolbox:
module_name: os_subnet
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
network_name: "{{ item.sharednet.name | default(default_sharednet_name) }}"
name: "{{ item.sharednet.name | default(default_sharednet_name) }}-subnet"
cidr: "{{ cidr }}"
allocation_pool_start: "{{ item.sharednet.allocation_pools[0].start | default(cidr | next_nth_usable(2)) }}"
allocation_pool_end: "{{ item.sharednet.allocation_pools[0].end | default(cidr | ipaddr('last_usable') | ipmath(-1)) }}"
vars:
cidr: "{{ item.sharednet.cidr | default(default_sharednet_cidr) }}"
loop: "{{ neutron_networks }}"
loop_control:
label: "{{ item.name }}"
become: true
run_once: True
when:
- item.sharednet is defined
- item.sharednet.enabled | default(true) | bool
register: sharednet_subnets
- name: Create NAT router for shared network(s).
kolla_toolbox:
module_name: os_router
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
name: sharednet-router
interfaces: "{{ sharednet_subnets.results | selectattr('subnet', 'defined') | map(attribute='subnet') | map(attribute='name') | list }}"
network: "{{ public_network.name }}"
external_fixed_ips:
- subnet: "public-subnet"
become: true
run_once: True
when:
- sharednet_subnets is defined
- public_network is defined
- public_network.name is defined
- public_network.cidr is defined