|
88 | 88 | ansible.builtin.set_fact:
|
89 | 89 | my_compartment_id: "{{ compartment_id | default(env_lookup, true | default(ini_lookup, true)) }}"
|
90 | 90 |
|
| 91 | + - name: Create oci state file |
| 92 | + ansible.builtin.file: |
| 93 | + patth: .ansible-state |
| 94 | + state: touch |
| 95 | + mode: "0755" |
| 96 | + |
| 97 | + - name: Add compartment id to state file |
| 98 | + ansible.builtin.lineinfile: |
| 99 | + path: .ansible-state |
| 100 | + line: "compartment_ocid: {{ my_compartment_id }}" |
| 101 | + mode: "0755" |
| 102 | + |
91 | 103 | - name: Print compartment id
|
92 | 104 | ansible.builtin.debug:
|
93 | 105 | msg: "{{ my_compartment_id }}"
|
|
119 | 131 | ansible.builtin.set_fact:
|
120 | 132 | my_vcn_id: "{{ result.vcn.id }}"
|
121 | 133 |
|
| 134 | + - name: Add vcn id to state file |
| 135 | + ansible.builtin.lineinfile: |
| 136 | + path: .ansible-state |
| 137 | + line: "vcn_ocid: {{ my_vcn_id }}" |
| 138 | + mode: "0755" |
| 139 | + |
122 | 140 | - name: Create internet gateway
|
123 | 141 | oracle.oci.oci_network_internet_gateway:
|
124 | 142 | compartment_id: "{{ my_compartment_id }}"
|
|
135 | 153 | ansible.builtin.set_fact:
|
136 | 154 | my_internet_gateway_id: "{{ result.internet_gateway.id }}"
|
137 | 155 |
|
| 156 | + - name: Add internet_gateway id to state file |
| 157 | + ansible.builtin.lineinfile: |
| 158 | + path: .ansible-state |
| 159 | + line: "internet_gateway_ocid: {{ my_internet_gateway_id }}" |
| 160 | + mode: "0755" |
| 161 | + |
138 | 162 | - name: Get list of services
|
139 | 163 | oracle.oci.oci_network_service_facts:
|
140 | 164 | register: result
|
|
151 | 175 | ansible.builtin.set_fact:
|
152 | 176 | my_service_id: "{{ result.services[0].id }}"
|
153 | 177 |
|
| 178 | + - name: Add service id to state file |
| 179 | + ansible.builtin.lineinfile: |
| 180 | + path: .ansible-state |
| 181 | + line: "service_ocid: {{ my_service_id }}" |
| 182 | + mode: "0755" |
| 183 | + |
154 | 184 | - name: Set service cidr cidr_block
|
155 | 185 | ansible.builtin.set_fact:
|
156 | 186 | my_service_cidr_block: "{{ result.services[0].cidr_block }}"
|
|
168 | 198 | delay: 30
|
169 | 199 | until: result is not failed
|
170 | 200 |
|
171 |
| - - name: Set services gateway id |
| 201 | + - name: Set service gateway id |
172 | 202 | ansible.builtin.set_fact:
|
173 | 203 | my_service_gateway_id: "{{ result.service_gateway.id }}"
|
174 | 204 |
|
| 205 | + - name: Add service gateway id to state file |
| 206 | + ansible.builtin.lineinfile: |
| 207 | + path: .ansible-state |
| 208 | + line: "service_gateway_ocid: {{ my_service_gateway_id }}" |
| 209 | + mode: "0755" |
| 210 | + |
175 | 211 | - name: Create route table for public subnet
|
176 | 212 | oracle.oci.oci_network_route_table:
|
177 | 213 | compartment_id: "{{ my_compartment_id }}"
|
|
192 | 228 | ansible.builtin.set_fact:
|
193 | 229 | my_public_rt_id: "{{ result.route_table.id }}"
|
194 | 230 |
|
| 231 | + - name: Add public route table id to state file |
| 232 | + ansible.builtin.lineinfile: |
| 233 | + path: .ansible-state |
| 234 | + line: "public_route_table_ocid: {{ my_public_rt_id }}" |
| 235 | + mode: "0755" |
| 236 | + |
195 | 237 | - name: Create route table for private subnet
|
196 | 238 | oracle.oci.oci_network_route_table:
|
197 | 239 | compartment_id: "{{ my_compartment_id }}"
|
|
212 | 254 | ansible.builtin.set_fact:
|
213 | 255 | my_private_rt_id: "{{ result.route_table.id }}"
|
214 | 256 |
|
| 257 | + - name: Add private route table id to state file |
| 258 | + ansible.builtin.lineinfile: |
| 259 | + path: .ansible-state |
| 260 | + line: "private_route_table_ocid: {{ my_private_rt_id }}" |
| 261 | + mode: "0755" |
| 262 | + |
215 | 263 | - name: Create ingress rules yaml list
|
216 | 264 | ansible.builtin.template:
|
217 | 265 | src: ingress_security_rules.j2
|
|
260 | 308 | ansible.builtin.set_fact:
|
261 | 309 | my_security_list_id: "{{ result.security_list.id }}"
|
262 | 310 |
|
| 311 | + - name: Add security list id to state file |
| 312 | + ansible.builtin.lineinfile: |
| 313 | + path: .ansible-state |
| 314 | + line: "security_list_ocid: {{ my_security_list_id }}" |
| 315 | + mode: "0755" |
| 316 | + |
263 | 317 | - name: Create public subnet
|
264 | 318 | oracle.oci.oci_network_subnet:
|
265 | 319 | compartment_id: "{{ my_compartment_id }}"
|
|
279 | 333 | ansible.builtin.set_fact:
|
280 | 334 | my_subnet1_id: "{{ result.subnet.id }}"
|
281 | 335 |
|
| 336 | + - name: Add public subnet id to state file |
| 337 | + ansible.builtin.lineinfile: |
| 338 | + path: .ansible-state |
| 339 | + line: "public_subnet_ocid: {{ my_subnet1_id }}" |
| 340 | + mode: "0755" |
| 341 | + |
282 | 342 | - name: Set public subnet domain_name
|
283 | 343 | ansible.builtin.set_fact:
|
284 | 344 | my_subnet1_domain_name: "{{ result.subnet.subnet_domain_name }}"
|
|
302 | 362 | ansible.builtin.set_fact:
|
303 | 363 | my_subnet2_id: "{{ result.subnet.id }}"
|
304 | 364 |
|
| 365 | + - name: Add private subnet id to state file |
| 366 | + ansible.builtin.lineinfile: |
| 367 | + path: .ansible-state |
| 368 | + line: "compartment_ocid: {{ my_subnet2_id }}" |
| 369 | + mode: "0755" |
| 370 | + |
305 | 371 | - name: Set private subnet domain_name
|
306 | 372 | ansible.builtin.set_fact:
|
307 | 373 | my_subnet2_domain_name: "{{ result.subnet.subnet_domain_name }}"
|
|
340 | 406 | - name: Build an instance
|
341 | 407 | ansible.builtin.include_tasks: "build.yml"
|
342 | 408 | loop: "{{ lookup('dict', compute_instances, wantlist=True) }}"
|
| 409 | + loop_control: |
| 410 | + extended: true |
343 | 411 |
|
344 | 412 | - name: Check if instances are available
|
345 | 413 | ansible.builtin.import_playbook: "check_instance_available.yml"
|
|
0 commit comments