From bdb2c566833ab8a98565fa5eb117995ae9b32592 Mon Sep 17 00:00:00 2001 From: spmfox Date: Tue, 30 May 2023 23:17:08 -0400 Subject: adding a rescue, if the VM fails to be created then the dataset is destroyed --- vm-create.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/vm-create.yml b/vm-create.yml index cfe9f8d..115be1d 100644 --- a/vm-create.yml +++ b/vm-create.yml @@ -21,8 +21,23 @@ apply: delegate_to: "{{ hypervisor_host }}" - - ansible.builtin.include_role: - name: libvirt - tasks_from: vm-install.yml - apply: - delegate_to: "{{ hypervisor_host }}" + - block: + - ansible.builtin.include_role: + name: libvirt + tasks_from: vm-install.yml + apply: + delegate_to: "{{ hypervisor_host }}" + + rescue: + - ansible.builtin.include_role: + name: zfs + tasks_from: dataset-confirm-info.yml + apply: + delegate_to: "{{ hypervisor_host }}" + + - ansible.builtin.include_role: + name: zfs + tasks_from: dataset-destroy.yml + apply: + delegate_to: "{{ hypervisor_host }}" + -- cgit