---
# Creates a dictionary for use with oVirt.vm-infra role
# https://github.com/oVirt/ovirt-ansible-vm-infra
- fail:
    msg: "The openshift_ovirt_dns_zone variable is required."
  when:
    - openshift_ovirt_dns_zone is none

- name: Create virtual machine list fact
  set_fact:
    vms: "{{ lookup('template', 'vms.j2') }}"
  tags:
    - openshift_ovirt

- name: Create affnity groups
  set_fact:
    affinity_groups: >-
      {% if ovirt_admin | default(True) -%}
      {{ affinity_groups|default([]) }} + [
        {% if item.count > 1 -%}
        {
      'name': '{{ item.name }}_ag',
      'cluster': '{{ openshift_ovirt_cluster }}',
      'vm_enforcing': 'false',
      'vm_rule': 'negative',
      'vms': [
        {% for iter in range(item.count) -%}
      '{{ item.name }}{{ iter }}.{{ openshift_ovirt_dns_zone }}',
        {% endfor -%}
      ]
        }
        {% endif -%}
      ]
      {% else -%}
      []
      {% endif -%}
  with_items: "{{ openshift_ovirt_vm_manifest }}"
  tags:
    - openshift_ovirt
...
