Fix XCP-NG delegate_to — use inline conditional to avoid empty hostname error

This commit is contained in:
Semaphore
2026-03-11 12:00:33 -07:00
parent bd1b99f47d
commit de36867075

View File

@@ -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" and xcpng_host != ""
delegate_to: "{{ xcpng_host | default('localhost') }}"
when: hypervisor_type == "xcpng" and xcpng_host | length > 0
delegate_to: "{{ xcpng_host if xcpng_host | length > 0 else '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" and xcpng_host != ""
delegate_to: "{{ xcpng_host | default('localhost') }}"
when: hypervisor_type == "xcpng" and xcpng_host | length > 0
delegate_to: "{{ xcpng_host if xcpng_host | length > 0 else 'localhost' }}"
- name: Assert snapshot exists before proceeding
ansible.builtin.assert: