Skip to content

Commit e1cf967

Browse files
committed
create service interfaces for cedges
1 parent 724168f commit e1cf967

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

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/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_edges/tasks/azure_cedge_vm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
admin_password: "{{ admin_password }}"
167167
mgmt_public_ip: "{{ cedge_mgmt_public_ip }}"
168168
transport_public_ip: "{{ cedge_transport_public_ip }}"
169+
uuid: "{{ uuid }}"
170+
site_id: "{{ site_id }}"
169171
changed_when: true
170172
notify: Show deployment_facts
171173

0 commit comments

Comments
 (0)