diff --git a/roles/snapshot/tasks/main.yml b/roles/snapshot/tasks/main.yml index e217cb1..10bdd0a 100644 --- a/roles/snapshot/tasks/main.yml +++ b/roles/snapshot/tasks/main.yml @@ -23,8 +23,8 @@ xe vm-snapshot vm={{ xcpng_vm_uuid }} new-name-label="{{ snapshot_name_prefix }}-{{ ansible_date_time.date }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}" register: xcpng_snapshot_result changed_when: xcpng_snapshot_result.rc == 0 - when: hypervisor_type == "xcpng" - delegate_to: "{{ xcpng_host }}" + when: hypervisor_type == "xcpng" and xcpng_host != "" + delegate_to: "{{ xcpng_host | default('localhost') }}" - name: Store XCP-NG snapshot UUID ansible.builtin.set_fact: @@ -50,8 +50,8 @@ register: xcpng_snap_verify changed_when: false failed_when: xcpng_snap_verify.stdout == "" - when: hypervisor_type == "xcpng" - delegate_to: "{{ xcpng_host }}" + when: hypervisor_type == "xcpng" and xcpng_host != "" + delegate_to: "{{ xcpng_host | default('localhost') }}" - name: Assert snapshot exists before proceeding ansible.builtin.assert: