Skip to content

Commit 3e0db90

Browse files
authored
Merge pull request #32 from cisco-open/config_groups
Create cEdge service interfaces
2 parents 724168f + e7ee20a commit 3e0db90

File tree

9 files changed

+160
-34
lines changed

9 files changed

+160
-34
lines changed

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace: cisco
22
name: sdwan_deployment
3-
version: 0.3.2
3+
version: 0.3.3
44
readme: README.md
55
authors:
66
- Arkadiusz Cichon <acichon@cisco.com>

playbooks/aws_sdwan_config.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ aws_vpc_cidr: 10.0.0.0/16 # default ips from official Cisco guides
3333
aws_igw_name: "{{ aws_resources_prefix }}-igw"
3434

3535
# SUBNETs
36-
aws_subnets:
36+
aws_subnets: |
37+
{% filter from_yaml %}
3738
- name: "{{ aws_resources_prefix }}-mgmt-subnet-512"
3839
subnet_cidr: "10.0.1.0/24" # default ips from official Cisco guides
3940
VPN: 512
@@ -42,10 +43,19 @@ aws_subnets:
4243
subnet_cidr: "10.0.2.0/24" # default ips from official Cisco guides
4344
VPN: 0
4445
type: transport
45-
# - name: "{{ aws_resources_prefix }}-cluster-subnet-0"
46-
# subnet_cidr: "10.0.3.0/24"
47-
# VPN: 0
48-
# type: cluster
46+
{% if vmanage_instances is defined and vmanage_instances | length > 2 %}
47+
- name: "{{ aws_resources_prefix }}-cluster-subnet-0"
48+
subnet_cidr: "10.0.3.0/24"
49+
VPN: 0
50+
type: cluster
51+
{% endif %}
52+
{% if ux20_deployment is defined and ux20_deployment == true %}
53+
- name: "{{ aws_resources_prefix }}-service-subnet-10"
54+
subnet_cidr: "10.0.4.0/24" # default ips from official Cisco guides
55+
VPN: 10
56+
type: service
57+
{% endif %}
58+
{% endfilter %}
4959
5060
# ROUTE TABLEs
5161
aws_route_table_name: "{{ aws_resources_prefix }}-rtab"

roles/aws_edges/tasks/aws_cedge_ec2_instance.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# NICs
1515
- name: Filter required subnets for instance creation. Set aws_mgmt_subnet and aws_transport_subnet facts
1616
ansible.builtin.set_fact:
17-
aws_mgmt_subnet: "{{ aws_subnets_config | selectattr('tags.VPN', 'equalto', '512') | list | first }}"
18-
aws_transport_subnet: "{{ aws_subnets_config | selectattr('tags.VPN', 'equalto', '0') | list | first }}"
17+
aws_mgmt_subnet: "{{ aws_subnets_config | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}"
18+
aws_transport_subnet: "{{ aws_subnets_config | selectattr('tags.type', 'equalto', 'transport') | list | first }}"
1919

2020
- name: Create network interfaces for cedge
2121
amazon.aws.ec2_eni:
@@ -28,21 +28,23 @@
2828
Creator: "{{ aws_tag_creator }}"
2929
Machine: "{{ hostname }}"
3030
VPN: "{{ subnet_item.tags.VPN }}"
31+
type: "{{ subnet_item.tags.type }}"
3132
register: network_interfaces_cedge
32-
loop: "{{ [aws_mgmt_subnet, aws_transport_subnet] }}"
33+
loop: "{{ aws_subnets_config }}"
3334
loop_control:
3435
loop_var: subnet_item
3536
label: "nic-{{ subnet_item.tags.Name }}"
37+
when: subnet_item.tags.type != "cluster"
3638

3739
- name: Set aws_network_interfaces fact with a list of interfaces for cEdge device
3840
ansible.builtin.set_fact:
3941
aws_network_interfaces: "{{ network_interfaces_cedge.results | map(attribute='interface') | list }}"
4042

4143
- name: Filter aws_network_interfaces for instance creation. Set aws_mgmt_nic and aws_transport_nic facts
4244
ansible.builtin.set_fact:
43-
aws_mgmt_nic: "{{ aws_network_interfaces | selectattr('tags.VPN', 'equalto', '512') | list | first }}"
44-
aws_transport_nic: "{{ aws_network_interfaces | selectattr('tags.VPN', 'equalto', '0') | list | first }}"
45-
45+
aws_mgmt_nic: "{{ aws_network_interfaces | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}"
46+
aws_transport_nic: "{{ aws_network_interfaces | selectattr('tags.type', 'equalto', 'transport') | list | first }}"
47+
aws_service_nics: "{{ aws_network_interfaces | selectattr('tags.type', 'equalto', 'service') | list | default(omit) }}"
4648

4749
# EIPs
4850
- name: Associate EIP with mgmt network interface
@@ -57,7 +59,7 @@
5759
Machine: "{{ hostname }}"
5860
VPN: "{{ interface_item.tags.VPN }}"
5961
register: eip_edge
60-
loop: "{{ [aws_mgmt_nic, aws_transport_nic] }}" # We do loop starting with mgmt nic, so we know results[0] is mgmt ip
62+
loop: "{{ [aws_mgmt_nic, aws_transport_nic] + (aws_service_nics | default([])) }}" # We do loop starting with mgmt nic, so we know results[0] is mgmt ip
6163
loop_control:
6264
loop_var: interface_item
6365
label: "eip-for-{{ interface_item.tags.Name }}"
@@ -79,7 +81,25 @@
7981
mode: "0644"
8082

8183

82-
# vManage
84+
- name: Set interfaces fact
85+
ansible.builtin.set_fact:
86+
interfaces:
87+
- id: "{{ aws_mgmt_nic.id }}"
88+
device_index: 0
89+
description: "{{ aws_mgmt_nic.tags.Name }}"
90+
- id: "{{ aws_transport_nic.id }}"
91+
device_index: 1
92+
description: "{{ aws_transport_nic.tags.Name }}"
93+
94+
- name: Append service interfaces
95+
ansible.builtin.set_fact:
96+
interfaces: "{{ interfaces + [{'id': nic.id, 'device_index': index + 2, 'description': nic.tags.Name}] }}"
97+
loop: "{{ (aws_service_nics | default([])) }}"
98+
loop_control:
99+
index_var: index
100+
loop_var: nic
101+
when: aws_service_nics is defined
102+
83103
- name: Launch cedge
84104
amazon.aws.ec2_instance:
85105
count: 1
@@ -92,13 +112,7 @@
92112
key_name: "{{ aws_key_name | default('') | bool | ternary(aws_key_name, omit) }}"
93113
network:
94114
assign_public_ip: false
95-
interfaces:
96-
- id: "{{ aws_mgmt_nic.id }}"
97-
device_index: 0
98-
description: "{{ aws_mgmt_nic.tags.Name }}"
99-
- id: "{{ aws_transport_nic.id }}"
100-
device_index: 1
101-
description: "{{ aws_transport_nic.tags.Name }}"
115+
interfaces: "{{ interfaces }}"
102116
name: "{{ hostname }}"
103117
tags:
104118
Name: "{{ hostname }}"
@@ -111,6 +125,19 @@
111125
delete_on_termination: true
112126
register: ec2_cedge
113127

128+
- name: Set service_interfaces fact
129+
ansible.builtin.set_fact:
130+
service_interfaces: []
131+
132+
- name: Append to service_interfaces
133+
ansible.builtin.set_fact:
134+
service_interfaces: "{{ service_interfaces + [{'addr': nic.private_ip_address, 'index': index + 2}] }}"
135+
loop: "{{ aws_service_nics }}"
136+
loop_control:
137+
loop_var: nic
138+
index_var: index
139+
when: aws_service_nics is defined
140+
114141
- name: Store cEdge instance details for deployment_results
115142
ansible.builtin.set_fact:
116143
instance:
@@ -120,7 +147,9 @@
120147
admin_password: "{{ admin_password }}"
121148
mgmt_public_ip: "{{ eip_edge.results[0].public_ip }}"
122149
transport_public_ip: "{{ eip_edge.results[1].public_ip }}"
150+
service_interfaces: "{{ service_interfaces | default(omit) }}"
123151
uuid: "{{ uuid }}"
152+
site_id: "{{ site_id }}"
124153
changed_when: true
125154
register: _edge_facts
126155
retries: 3

roles/aws_network_infrastructure/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ aws_subnets: |
4343
VPN: 0
4444
type: cluster
4545
{% endif %}
46+
{% if ux20_deployment is defined and ux20_deployment == true %}
47+
- name: "{{ aws_resources_prefix }}-service-subnet-10"
48+
subnet_cidr: "10.0.4.0/24" # default ips from official Cisco guides
49+
VPN: 10
50+
type: service
51+
{% endif %}
4652
{% endfilter %}
4753
4854
# ROUTE TABLEs

roles/aws_network_infrastructure/tasks/aws_create_network_infrastructure.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@
6363
state: present
6464
vpc_id: "{{ _created_vpc.vpc.id }}"
6565
cidr: "{{ subnet_config.subnet_cidr }}"
66-
map_public: "{{ subnet_config.type != 'cluster' }}"
66+
map_public: "{{ subnet_config.type in ['mgmt', 'transport'] }}"
6767
region: "{{ aws_region }}"
6868
az: "{{ aws_availibility_zone }}"
6969
tags:
7070
Name: "{{ subnet_config.name }}"
7171
Creator: "{{ aws_tag_creator }}"
7272
VPN: "{{ subnet_config.VPN }}"
73+
type: "{{ subnet_config.type }}"
7374
register: _created_subnets
7475
loop: "{{ aws_subnets }}"
7576
loop_control:

roles/azure_controllers/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ az_subnets: |
3737
VPN: 0
3838
type: cluster
3939
{% endif %}
40+
{% if ux20_deployment is defined and ux20_deployment == true %}
41+
- name: "{{ az_resources_prefix }}-service-subnet-10"
42+
cidr: "10.0.4.0/24" # default ips from official Cisco guides
43+
VPN: 10
44+
type: service
45+
{% endif %}
4046
{% endfilter %}
4147
4248
# Security group

roles/azure_edges/defaults/main.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ az_virtual_network: "{{ az_resources_prefix }}-vn"
2121
az_vn_address_prefixes_cidr: 10.0.0.0/16
2222

2323
# Subnets
24-
az_subnets:
24+
az_subnets: |
25+
{% filter from_yaml %}
2526
- name: "{{ az_resources_prefix }}-mgmt-subnet-512"
2627
cidr: "10.0.1.0/24"
2728
VPN: 512
@@ -30,10 +31,19 @@ az_subnets:
3031
cidr: "10.0.2.0/24"
3132
VPN: 0
3233
type: transport
33-
# - name: "{{ az_resources_prefix }}-cluster-subnet-0"
34-
# cidr: "10.0.3.0/24"
35-
# VPN: 0
36-
# type: cluster
34+
{% if vmanage_instances is defined and vmanage_instances | length > 2 %}
35+
- name: "{{ az_resources_prefix }}-cluster-subnet-0"
36+
cidr: "10.0.3.0/24"
37+
VPN: 0
38+
type: cluster
39+
{% endif %}
40+
{% if ux20_deployment is defined and ux20_deployment == true %}
41+
- name: "{{ az_resources_prefix }}-service-subnet-10"
42+
cidr: "10.0.4.0/24" # default ips from official Cisco guides
43+
VPN: 10
44+
type: service
45+
{% endif %}
46+
{% endfilter %}
3747
3848
# Security group
3949
az_network_security_group: "{{ az_resources_prefix }}-nsg"

roles/azure_edges/tasks/azure_cedge_vm.yml

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Machine: "{{ hostname }}"
2020
VPN: "{{ subnet_item.VPN }}"
2121
Subnet: "{{ subnet_item.name }}"
22+
type: "{{ subnet_item.type }}"
2223
loop:
2324
- "{{ mgmt_subnet }}"
2425
- "{{ transport_subnet }}"
@@ -72,24 +73,55 @@
7273
Creator: "{{ az_tag_creator }}"
7374
Organization: "{{ organization_name }}"
7475
VPN: "{{ public_ip_state.state.tags.VPN }}"
76+
type: "{{ public_ip_state.state.tags.type }}"
7577
loop: "{{ public_ip_addresses.results }}"
7678
loop_control:
7779
loop_var: public_ip_state
7880
index_var: my_idx
7981
label: public_ip_state.state.name
8082
register: cedge_nics
8183

84+
- name: "Create private virtual network interface cards"
85+
azure.azcollection.azure_rm_networkinterface:
86+
resource_group: "{{ az_resource_group }}"
87+
name: "nic-{{ hostname }}-vpn-{{ subnet.VPN }}"
88+
virtual_network: "{{ az_virtual_network }}"
89+
subnet_name: "{{ subnet.name }}"
90+
security_group: "{{ az_network_security_group }}"
91+
ip_configurations:
92+
- name: "ipconfig-vpn-{{ subnet.VPN }}"
93+
private_ip_allocation_method: "Dynamic"
94+
tags:
95+
Name: "nic-{{ hostname }}-vpn-{{ subnet.VPN }}"
96+
Creator: "{{ az_tag_creator }}"
97+
Organization: "{{ organization_name }}"
98+
VPN: "{{ subnet.VPN }}"
99+
type: "{{ subnet.type }}"
100+
loop: "{{ az_subnets }}"
101+
loop_control:
102+
loop_var: subnet
103+
index_var: my_idx
104+
label: subnet.name
105+
register: cedge_private_nics
106+
when: subnet.type == "service"
107+
82108
- name: Set az_network_interfaces_cedge fact with a list of interfaces for cedge
83109
ansible.builtin.set_fact:
84110
az_network_interfaces_cedge: "{{ cedge_nics.results | map(attribute='state') | list }}"
111+
az_private_network_interfaces_cedge: "{{ cedge_private_nics.results | selectattr('state', 'defined') | map(attribute='state') | list | default([]) }}"
85112
az_public_ip_addresses_cedge: "{{ public_ip_addresses.results | map(attribute='state') | list }}"
86113

114+
- name: Append to az_network_interfaces_cedge
115+
ansible.builtin.set_fact:
116+
az_network_interfaces_cedge: "{{ az_network_interfaces_cedge + az_private_network_interfaces_cedge }}"
117+
87118
- name: Filter az_network_interfaces_cedge for instance creation. Set az_mgmt_nic and az_transport_nic facts
88119
ansible.builtin.set_fact:
89-
az_mgmt_nic: "{{ az_network_interfaces_cedge | selectattr('tags.VPN', 'equalto', '512') | list | first }}"
90-
az_transport_nic: "{{ az_network_interfaces_cedge | selectattr('tags.VPN', 'equalto', '0') | list | first }}"
91-
az_mgmt_public_ip: "{{ az_public_ip_addresses_cedge | selectattr('tags.VPN', 'equalto', '512') | list | first }}"
92-
az_transport_public_ip: "{{ az_public_ip_addresses_cedge | selectattr('tags.VPN', 'equalto', '0') | list | first }}"
120+
az_mgmt_nic: "{{ az_network_interfaces_cedge | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}"
121+
az_transport_nic: "{{ az_network_interfaces_cedge | selectattr('tags.type', 'equalto', 'transport') | list | first }}"
122+
az_service_nics: "{{ az_network_interfaces_cedge | selectattr('tags.type', 'equalto', 'service') | list | default(omit) }}"
123+
az_mgmt_public_ip: "{{ az_public_ip_addresses_cedge | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}"
124+
az_transport_public_ip: "{{ az_public_ip_addresses_cedge | selectattr('tags.type', 'equalto', 'transport') | list | first }}"
93125

94126
# cedge_mgmt_private_ip
95127
- name: "Set ip addresses cedge facts"
@@ -120,6 +152,18 @@
120152
dest: "{{ generated_userdata_cedge }}"
121153
mode: "0644"
122154

155+
- name: "Set network_interfaces fact"
156+
ansible.builtin.set_fact:
157+
network_interfaces: "{{ [az_mgmt_nic.id, az_transport_nic.id] }}"
158+
159+
- name: "Append service NICs to network_interfaces fact"
160+
ansible.builtin.set_fact:
161+
network_interfaces: "{{ network_interfaces + [service_nic.id] }}"
162+
loop: "{{ az_service_nics }}"
163+
loop_control:
164+
loop_var: service_nic
165+
when: az_service_nics is defined
166+
123167
- name: "Create cedge VM: {{ hostname }}"
124168
azure.azcollection.azure_rm_virtualmachine:
125169
resource_group: "{{ az_resource_group }}"
@@ -136,9 +180,7 @@
136180
ephemeral_os_disk: false
137181
linux_config:
138182
disable_password_authentication: false
139-
network_interfaces:
140-
- "{{ az_mgmt_nic.id }}"
141-
- "{{ az_transport_nic.id }}"
183+
network_interfaces: "{{ network_interfaces }}"
142184
image:
143185
offer: "{{ az_cedge_image_offer }}"
144186
publisher: "{{ az_cedge_image_publisher }}"
@@ -157,6 +199,19 @@
157199
Organization: "{{ organization_name }}"
158200
custom_data: "{{ lookup('file', generated_userdata_cedge) }}"
159201

202+
- name: Set service_interfaces fact
203+
ansible.builtin.set_fact:
204+
service_interfaces: []
205+
206+
- name: Append to service_interfaces
207+
ansible.builtin.set_fact:
208+
service_interfaces: "{{ service_interfaces + [{'addr': nic.ip_configuration.private_ip_address, 'index': index + 2}] }}"
209+
loop: "{{ az_service_nics }}"
210+
loop_control:
211+
loop_var: nic
212+
index_var: index
213+
when: az_service_nics is defined
214+
160215
- name: Store cEdge instance details for deployment_results
161216
ansible.builtin.set_fact:
162217
instance:
@@ -166,6 +221,9 @@
166221
admin_password: "{{ admin_password }}"
167222
mgmt_public_ip: "{{ cedge_mgmt_public_ip }}"
168223
transport_public_ip: "{{ cedge_transport_public_ip }}"
224+
service_interfaces: "{{ service_interfaces | default(omit) }}"
225+
uuid: "{{ uuid }}"
226+
site_id: "{{ site_id }}"
169227
changed_when: true
170228
notify: Show deployment_facts
171229

roles/azure_network_infrastructure/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ az_subnets: |
3737
VPN: 0
3838
type: cluster
3939
{% endif %}
40+
{% if ux20_deployment is defined and ux20_deployment == true %}
41+
- name: "{{ az_resources_prefix }}-service-subnet-10"
42+
cidr: "10.0.4.0/24" # default ips from official Cisco guides
43+
VPN: 10
44+
type: service
45+
{% endif %}
4046
{% endfilter %}
4147
4248
# Security group

0 commit comments

Comments
 (0)