aboutsummaryrefslogtreecommitdiff
path: root/vm-delete.yml
blob: e1173267bca49545a80711a2b15b1f039dfafc70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- hosts: all
  become: true
  gather_facts: false

  tasks:
    - name: Import zfs role to check if dataset exists
      ansible.builtin.include_role:
        name: zfs
        tasks_from: dataset-check-exists.yml
        apply:
          tags: zfs
          delegate_to: "{{ hypervisor_host }}"
      tags: zfs

    - name: Import libvirt role to check if VM exists
      ansible.builtin.include_role:
        name: libvirt
        tasks_from: vm-check-exists.yml
        apply:
          tags: libvirt
          delegate_to: "{{ hypervisor_host }}"
      tags: libvirt

    - name: Import libvirt role to confirm if VM has expected configuration
      ansible.builtin.include_role:
        name: libvirt
        tasks_from: vm-confirm-info.yml
        apply:
          tags: libvirt
          delegate_to: "{{ hypervisor_host }}"
      tags: libvirt

    - name: Import zfs role to confirm if the dataset has expected configuration
      ansible.builtin.include_role:
        name: zfs
        tasks_from: dataset-confirm-info.yml
        apply:
          tags: zfs
          delegate_to: "{{ hypervisor_host }}"
      tags: zfs

    - name: Import guest-configure role for undo
      ansible.builtin.include_role:
        name: guest-configure
        tasks_from: undo.yml
        apply:
          tags: guest-configure
      tags: guest-configure
      when: (ssh_key is defined and ssh_key | length > 0) or (root_password is defined and root_password | length > 0)

    - name: Import libvirt role to undefine VM
      ansible.builtin.include_role:
        name: libvirt
        tasks_from: vm-undefine.yml
        apply:
          tags: libvirt
          delegate_to: "{{ hypervisor_host }}"
      tags: libvirt

    - name: Import zfs role to destroy the dataset
      ansible.builtin.include_role:
        name: zfs
        tasks_from: dataset-destroy.yml
        apply:
          tags: zfs
          delegate_to: "{{ hypervisor_host }}"
      tags: zfs