A dev environment for the mirror.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mirror-env/libvirt/cleanup.yml

49 lines
1.2 KiB

---
- name: delete the mirror vm
hosts: 127.0.0.1
gather_facts: no
become: yes
tasks:
- name: mirbr0 network exists
command: "virsh -c qemu:///system net-dumpxml mirbr0"
changed_when: false
ignore_errors: true
register: net_exists
- name: storage pool exists
command: "virsh -c qemu:///system pool-dumpxml mirror"
changed_when: false
ignore_errors: true
register: pool_exists
- name: mirror vm exists
command: "virsh -c qemu:///system dumpxml mirror"
changed_when: false
ignore_errors: true
register: vm_exists
- name: delete vm
command: "virsh -c qemu:///system {{ item }}"
loop:
- destroy mirror
- undefine --nvram mirror
when: vm_exists.rc == 0
- name: delete storage pool
command: "virsh -c qemu:///system {{ item }}"
loop:
- pool-destroy mirror
- pool-undefine mirror
when: pool_exists.rc == 0
- name: delete mirbr0 bridge network
command: "virsh -c qemu:///system {{ item }}"
loop:
- net-destroy mirbr0
- net-undefine mirbr0
when: net_exists.rc == 0
- name: delete directory for vm
file:
path: "{{ playbook_dir }}/vm"
state: absent