Skip to content

Commit 540b7f1

Browse files
committed
add helper playbooks and split out termination
1 parent 4bed5ce commit 540b7f1

File tree

5 files changed

+165
-72
lines changed

5 files changed

+165
-72
lines changed

olvm/create_instance.yml

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -415,73 +415,4 @@
415415
Aborting at this stage requires manual removal of all cloud resources this playbook creates.
416416
417417
- name: Terminate instances and delete OCI resources
418-
hosts: localhost
419-
vars_files:
420-
- default_vars.yml
421-
422-
tasks:
423-
424-
- name: Terminate the instances
425-
oracle.oci.oci_compute_instance:
426-
id: "{{ hostvars[item]['instance_ocid'] }}"
427-
state: absent
428-
loop: "{{ groups['all'] | difference(['localhost']) }}"
429-
430-
- name: Delete the vlan
431-
oracle.oci.oci_network_vlan:
432-
vlan_id: "{{ my_vlan_id }}"
433-
state: absent
434-
435-
- name: Delete network_security_group
436-
oracle.oci.oci_network_security_group:
437-
network_security_group_id: "{{ my_l2_vlan_nsg_id }}"
438-
state: absent
439-
440-
- name: Delete the subnet2
441-
oracle.oci.oci_network_subnet:
442-
id: "{{ my_subnet2_id }}"
443-
state: absent
444-
445-
- name: Delete the subnet1
446-
oracle.oci.oci_network_subnet:
447-
id: "{{ my_subnet1_id }}"
448-
state: absent
449-
450-
- name: Delete the security list
451-
oracle.oci.oci_network_security_list:
452-
id: "{{ my_security_list_id }}"
453-
state: absent
454-
455-
- name: Delete the private route table
456-
oracle.oci.oci_network_route_table:
457-
id: "{{ my_private_rt_id }}"
458-
state: absent
459-
460-
- name: Delete the public route table
461-
oracle.oci.oci_network_route_table:
462-
id: "{{ my_public_rt_id }}"
463-
state: absent
464-
465-
- name: Delete the Service Gateway
466-
oracle.oci.oci_network_service_gateway:
467-
id: "{{ my_service_gateway_id }}"
468-
state: absent
469-
470-
- name: Delete the Internet Gateway
471-
oracle.oci.oci_network_internet_gateway:
472-
id: "{{ my_internet_gateway_id }}"
473-
state: absent
474-
475-
- name: Delete the VCN
476-
oracle.oci.oci_network_vcn:
477-
vcn_id: "{{ my_vcn_id }}"
478-
state: absent
479-
480-
- name: Remove artifacts
481-
ansible.builtin.file:
482-
state: absent
483-
path: "{{ item }}"
484-
loop:
485-
- oci_vars.yml
486-
- buffer
487-
- hosts
418+
ansible.builtin.import_playbook: "terminate_instance.yml"

olvm/ovirt_check_hosts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
loop: "{{ groups['kvm'] }}"
5050
loop_control:
5151
extended: true
52-
retries: 30 # Number of times to retry
53-
delay: 10 # Delay between retries in seconds
52+
retries: 40 # Number of times to retry
53+
delay: 15 # Delay between retries in seconds
5454

5555
- name: Print host status
5656
ansible.builtin.debug:

olvm/ovirt_delete_host.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# Copyright (c) 2024 2025 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Delete a failed host
8+
hosts: olvm
9+
vars_files:
10+
- default_vars.yml
11+
- oci_vars.yml
12+
vars:
13+
ansible_python_interpreter: "/usr/bin/{{ ovirt_python_version }}"
14+
15+
tasks:
16+
17+
- name: Connect to the OLVM Engine application # noqa: syntax-check[unknown-module]
18+
ovirt.ovirt.ovirt_auth:
19+
url: "{{ engine_url }}"
20+
username: "{{ engine_user }}"
21+
password: "{{ engine_pass }}"
22+
ca_file: "{{ ansible_env.HOME + '/pki-resource' }}"
23+
insecure: true
24+
when: ovirt_auth is undefined or not ovirt_auth
25+
register: auth_connection
26+
tags:
27+
- always
28+
29+
- name: Remove the specific host
30+
ovirt.ovirt.ovirt_host:
31+
auth: "{{ ovirt_auth }}"
32+
state: absent
33+
name: "{{ name_of_host }}"
34+
force: true
35+
36+
- name: Disconnect from the OLVM Engine application
37+
ovirt.ovirt.ovirt_auth:
38+
state: absent
39+
ovirt_auth: "{{ ovirt_auth }}"
40+
tags:
41+
- always

olvm/ovirt_list_hosts.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# Copyright (c) 2024 2025 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Get list of kvm hosts
8+
hosts: olvm
9+
vars_files:
10+
- default_vars.yml
11+
- oci_vars.yml
12+
vars:
13+
ansible_python_interpreter: "/usr/bin/{{ ovirt_python_version }}"
14+
15+
tasks:
16+
17+
- name: Connect to the OLVM Engine application # noqa: syntax-check[unknown-module]
18+
ovirt.ovirt.ovirt_auth:
19+
url: "{{ engine_url }}"
20+
username: "{{ engine_user }}"
21+
password: "{{ engine_pass }}"
22+
ca_file: "{{ ansible_env.HOME + '/pki-resource' }}"
23+
insecure: true
24+
when: ovirt_auth is undefined or not ovirt_auth
25+
register: auth_connection
26+
tags:
27+
- always
28+
29+
- name: Gather host inforamtion
30+
ovirt.ovirt.ovirt_host_info:
31+
pattern: name=olkvm*
32+
auth: "{{ ovirt_auth }}"
33+
register: host_info
34+
35+
- name: Print host_info
36+
ansible.builtin.debug:
37+
msg: "{{ host_info.ovirt_hosts }}"
38+
39+
- name: Disconnect from the OLVM Engine application
40+
ovirt.ovirt.ovirt_auth:
41+
state: absent
42+
ovirt_auth: "{{ ovirt_auth }}"
43+
tags:
44+
- always

olvm/terminate_instance.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
# Copyright (c) 2024 2025 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Terminate instances and delete OCI resources
8+
hosts: localhost
9+
vars_files:
10+
- default_vars.yml
11+
12+
tasks:
13+
14+
- name: Terminate the instances
15+
oracle.oci.oci_compute_instance:
16+
id: "{{ hostvars[item]['instance_ocid'] }}"
17+
state: absent
18+
loop: "{{ groups['engine'] + groups['kvm'] }}"
19+
20+
- name: Delete the vlan
21+
oracle.oci.oci_network_vlan:
22+
vlan_id: "{{ my_vlan_id }}"
23+
state: absent
24+
25+
- name: Delete network_security_group
26+
oracle.oci.oci_network_security_group:
27+
network_security_group_id: "{{ my_l2_vlan_nsg_id }}"
28+
state: absent
29+
30+
- name: Delete the subnet2
31+
oracle.oci.oci_network_subnet:
32+
id: "{{ my_subnet2_id }}"
33+
state: absent
34+
35+
- name: Delete the subnet1
36+
oracle.oci.oci_network_subnet:
37+
id: "{{ my_subnet1_id }}"
38+
state: absent
39+
40+
- name: Delete the security list
41+
oracle.oci.oci_network_security_list:
42+
id: "{{ my_security_list_id }}"
43+
state: absent
44+
45+
- name: Delete the private route table
46+
oracle.oci.oci_network_route_table:
47+
id: "{{ my_private_rt_id }}"
48+
state: absent
49+
50+
- name: Delete the public route table
51+
oracle.oci.oci_network_route_table:
52+
id: "{{ my_public_rt_id }}"
53+
state: absent
54+
55+
- name: Delete the Service Gateway
56+
oracle.oci.oci_network_service_gateway:
57+
id: "{{ my_service_gateway_id }}"
58+
state: absent
59+
60+
- name: Delete the Internet Gateway
61+
oracle.oci.oci_network_internet_gateway:
62+
id: "{{ my_internet_gateway_id }}"
63+
state: absent
64+
65+
- name: Delete the VCN
66+
oracle.oci.oci_network_vcn:
67+
vcn_id: "{{ my_vcn_id }}"
68+
state: absent
69+
70+
- name: Remove artifacts
71+
ansible.builtin.file:
72+
state: absent
73+
path: "{{ item }}"
74+
loop:
75+
- oci_vars.yml
76+
- buffer
77+
- hosts

0 commit comments

Comments
 (0)