Initial commit: Turbo Mothership bare metal management cluster
- k0s bootstrap with Cilium and OpenEBS - ArgoCD apps for infra, CAPI, Tinkerbell, and Netris - Ansible playbooks for virtual baremetal lab and Netris switches - CAPI provider manifests for k0smotron and Tinkerbell
This commit is contained in:
52
ansible/virtual-bm/destroy-vms.yml
Normal file
52
ansible/virtual-bm/destroy-vms.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
- name: Destroy virtual baremetal VMs and VirtualBMC
|
||||
hosts: local
|
||||
become: true
|
||||
gather_facts: false
|
||||
|
||||
vars:
|
||||
disk_path: /var/lib/libvirt/images
|
||||
vms:
|
||||
- name: vm1
|
||||
- name: vm2
|
||||
- name: vm3
|
||||
|
||||
tasks:
|
||||
- name: Stop VBMC for each VM
|
||||
ansible.builtin.command: vbmc stop {{ item.name }}
|
||||
loop: "{{ vms }}"
|
||||
failed_when: false
|
||||
changed_when: true
|
||||
|
||||
- name: Delete VBMC entries
|
||||
ansible.builtin.command: vbmc delete {{ item.name }}
|
||||
loop: "{{ vms }}"
|
||||
failed_when: false
|
||||
changed_when: true
|
||||
|
||||
- name: Destroy VMs
|
||||
ansible.builtin.command: virsh destroy {{ item.name }}
|
||||
loop: "{{ vms }}"
|
||||
failed_when: false
|
||||
changed_when: true
|
||||
|
||||
- name: Undefine VMs with NVRAM
|
||||
ansible.builtin.command: virsh undefine {{ item.name }} --nvram
|
||||
loop: "{{ vms }}"
|
||||
failed_when: false
|
||||
changed_when: true
|
||||
|
||||
- name: Remove VM disk images
|
||||
ansible.builtin.file:
|
||||
path: "{{ disk_path }}/{{ item.name }}-disk.img"
|
||||
state: absent
|
||||
loop: "{{ vms }}"
|
||||
|
||||
- name: Get remaining VM list
|
||||
ansible.builtin.command: virsh list --all
|
||||
register: vm_list
|
||||
changed_when: false
|
||||
|
||||
- name: Display VM list
|
||||
ansible.builtin.debug:
|
||||
var: vm_list.stdout_lines
|
||||
Reference in New Issue
Block a user