---
- name: Ensure Kolla Bifrost is configured
  hosts: localhost
  tags:
    - kolla-bifrost
  vars:
    kolla_bifrost_extra_globals_path: "{{ kayobe_config_path ~ '/kolla/config/bifrost/bifrost.yml' }}"

  pre_tasks:
    - name: Check whether a Kolla Bifrost extra globals configuration file exists
      stat:
        path: "{{ kolla_bifrost_extra_globals_path }}"
        get_checksum: False
        get_md5: False
        mime: False
      register: globals_stat

    - name: Read the Kolla Bifrost extra globals configuration file
      set_fact:
        kolla_bifrost_extra_globals: "{{ lookup('template', kolla_bifrost_extra_globals_path) | from_yaml }}"
      when: globals_stat.stat.exists

  roles:
    - role: kolla-bifrost

      # Network configuration.
      kolla_bifrost_dhcp_pool_start: "{{ provision_oc_net_name | net_inspection_allocation_pool_start }}"
      kolla_bifrost_dhcp_pool_end: "{{ provision_oc_net_name | net_inspection_allocation_pool_end }}"
      kolla_bifrost_dnsmasq_router: "{{ provision_oc_net_name | net_gateway }}"
      kolla_bifrost_dnsmasq_dns_servers: "{{ resolv_nameservers | default([]) }}"
      kolla_bifrost_domain: "{{ resolv_domain | default }}"
      kolla_bifrost_download_ipa: "{{ not ipa_build_images | bool }}"
