Files
turbo-mothership/ansible/virtual-bm/destroy-vms.yml
Pavel Basov df9937f0c3 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
2025-12-15 19:59:58 +01:00

53 lines
1.3 KiB
YAML

---
- 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