---

- block:

    - name: wait for server to stop responding
      wait_for:
        host: "{{ template_vm_ip_address }}"
        port: "{{ vm_ansible_port | default('5986') }}"
        timeout: 120
        state: stopped
      ignore_errors: yes

    - include_tasks: wait_vm_poweredoff_pre29.yml
      when: ansible_version.full is version('2.9', '<')

    - include_tasks: wait_vm_poweredoff.yml
      when: ansible_version.full is version('2.9', '>=')

  rescue:
    - name: ignoring any error
      debug:
        msg: "ignoring error..."

- name: reconfigure vm
  ovirt_vm:
    auth: "{{ ovirt_auth }}"
    cluster: "{{ providers.ovirt.cluster }}"
    name: "{{ template.name }}"
    boot_devices:
      - hd
    cd_iso: ""
    custom_properties: "{{ custom_properties_efi if template_vm_efi|bool else '' }}"
    force: yes
    state: present
  when: template is defined