|
103 | 103 | - name: Create a virtual cloud network
|
104 | 104 | oracle.oci.oci_network_vcn:
|
105 | 105 | compartment_id: "{{ my_compartment_id }}"
|
106 |
| - display_name: "Linuxvirt Virtual Cloud Network" |
| 106 | + display_name: "OLV-VCN" |
107 | 107 | cidr_blocks: "10.0.0.0/16"
|
108 |
| - dns_label: "vcn" |
| 108 | + dns_label: "olv" |
109 | 109 | register: result
|
110 | 110 | retries: 10
|
111 | 111 | delay: 30
|
|
115 | 115 | ansible.builtin.set_fact:
|
116 | 116 | my_vcn_id: "{{ result.vcn.id }}"
|
117 | 117 |
|
118 |
| - - name: Create internet_gateway |
| 118 | + - name: Create internet gateway |
119 | 119 | oracle.oci.oci_network_internet_gateway:
|
120 | 120 | compartment_id: "{{ my_compartment_id }}"
|
121 | 121 | vcn_id: "{{ my_vcn_id }}"
|
122 | 122 | is_enabled: true
|
123 |
| - display_name: "Linuxvirt Internet Gateway" |
| 123 | + display_name: "Internet Gateway-OLV-VCN" |
124 | 124 | state: 'present'
|
125 | 125 | register: result
|
126 | 126 | retries: 10
|
|
131 | 131 | ansible.builtin.set_fact:
|
132 | 132 | my_internet_gateway_id: "{{ result.internet_gateway.id }}"
|
133 | 133 |
|
134 |
| - - name: Create route_table |
| 134 | + - name: Get list of services |
| 135 | + oracle.oci.oci_network_service_facts: |
| 136 | + register: result |
| 137 | + retries: 10 |
| 138 | + delay: 30 |
| 139 | + until: result is not failed |
| 140 | + |
| 141 | + - name: Set service id |
| 142 | + ansible.builtin.set_fact: |
| 143 | + my_service_id: "{{ result[0].service.id }}" |
| 144 | + |
| 145 | + - name: Create service gateway |
| 146 | + oracle.oci.oci_network_service_gateway: |
| 147 | + compartment_id: "{{ my_compartment_id }}" |
| 148 | + services: |
| 149 | + - |
| 150 | + service_id: "{{ my_service_id }}" |
| 151 | + vcn_id: "{{ my_vcn_id }}" |
| 152 | + display_name: "Service Gateway-OLV-VCN" |
| 153 | + state: 'present' |
| 154 | + register: result |
| 155 | + retries: 10 |
| 156 | + delay: 30 |
| 157 | + until: result is not failed |
| 158 | + |
| 159 | + - name: Set services gateway id |
| 160 | + ansible.builtin.set_fact: |
| 161 | + my_service_gateway_id: "{{ result.service_gateway.id }}" |
| 162 | + |
| 163 | + - name: Create route table for private subnet |
135 | 164 | oracle.oci.oci_network_route_table:
|
136 | 165 | compartment_id: "{{ my_compartment_id }}"
|
137 | 166 | vcn_id: "{{ my_vcn_id }}"
|
138 |
| - display_name: "Linuxvirt Route Table" |
| 167 | + display_name: "Route Table for Private Subnet-OLV-VCN" |
139 | 168 | route_rules:
|
140 |
| - - network_entity_id: "{{ my_internet_gateway_id }}" |
141 |
| - cidr_block: "0.0.0.0/0" |
142 |
| - destination_type: CIDR_BLOCK |
| 169 | + - network_entity_id: "{{ my_service_gateway_id }}" |
143 | 170 | state: 'present'
|
144 | 171 | register: result
|
145 | 172 | retries: 10
|
146 | 173 | delay: 30
|
147 | 174 | until: result is not failed
|
148 | 175 |
|
149 |
| - - name: Set route table id |
| 176 | + - name: Set private subnet route table id |
150 | 177 | ansible.builtin.set_fact:
|
151 |
| - my_rt_id: "{{ result.route_table.id }}" |
| 178 | + my_private_rt_id: "{{ result.route_table.id }}" |
152 | 179 |
|
153 | 180 | - name: Create ingress rules yaml list
|
154 | 181 | ansible.builtin.template:
|
|
184 | 211 |
|
185 | 212 | - name: Create security_list
|
186 | 213 | oracle.oci.oci_network_security_list:
|
187 |
| - display_name: "Linuxvirt Security List" |
| 214 | + display_name: "Security List for "OLV-VCN" |
188 | 215 | compartment_id: "{{ my_compartment_id }}"
|
189 | 216 | vcn_id: "{{ my_vcn_id }}"
|
190 | 217 | ingress_security_rules: "{{ loaded_ingress.instance_ingress_security_rules }}"
|
|
205 | 232 | cidr_block: "{{ subnet1_cidr_block }}"
|
206 | 233 | display_name: "Public Subnet-OLV-VCN"
|
207 | 234 | prohibit_public_ip_on_vnic: false
|
208 |
| - route_table_id: "{{ my_rt_id }}" |
209 |
| - security_list_ids: "{{ my_security_list_id }}" |
210 |
| - dns_label: "olvpub" |
| 235 | + dns_label: "pub" |
211 | 236 | register: result
|
212 | 237 | retries: 10
|
213 | 238 | delay: 30
|
|
228 | 253 | cidr_block: "{{ subnet2_cidr_block }}"
|
229 | 254 | display_name: "Private Subnet-OLV-VCN"
|
230 | 255 | prohibit_public_ip_on_vnic: true
|
231 |
| - route_table_id: "{{ my_rt_id }}" |
| 256 | + route_table_id: "{{ my_private_rt_id }}" |
232 | 257 | security_list_ids: "{{ my_security_list_id }}"
|
233 |
| - dns_label: "olvpriv" |
| 258 | + dns_label: "priv" |
234 | 259 | register: result
|
235 | 260 | retries: 10
|
236 | 261 | delay: 30
|
|
346 | 371 |
|
347 | 372 | - name: Delete network_security_group
|
348 | 373 | oracle.oci.oci_network_security_group:
|
349 |
| - network_security_group_id: "{{ my_nsg_id }}" |
| 374 | + network_security_group_id: "{{ my_l2_vlan_nsg_id }}" |
350 | 375 | state: absent
|
351 | 376 |
|
352 | 377 | - name: Delete the subnet2
|
|
366 | 391 |
|
367 | 392 | - name: Delete the route table
|
368 | 393 | oracle.oci.oci_network_route_table:
|
369 |
| - id: "{{ my_rt_id }}" |
| 394 | + id: "{{ my_private_rt_id }}" |
370 | 395 | state: absent
|
371 | 396 |
|
| 397 | + - name: Delete the Service Gateway |
| 398 | + oracle.oci.oci_network_service_gateway: |
| 399 | + id: "{{ my_service_gateway_id }}" |
| 400 | + state: absent |
| 401 | + |
372 | 402 | - name: Delete the Internet Gateway
|
373 | 403 | oracle.oci.oci_network_internet_gateway:
|
374 | 404 | id: "{{ my_internet_gateway_id }}"
|
|
0 commit comments