---
- name: gather facts used by role
  setup:
    gather_subset: "!min,pkg_mgr"
  when: >
    ansible_pkg_mgr is not defined

- name: Create repo setup script
  template:
    src: "{{ ib_repo_install_script }}"
    dest: "{{ ib_repo_workdir }}/install-built-repo.sh"
    mode: 0755

- when: ib_repo_host is defined
  block:
    - name: Fetch repo to localhost
      fetch: "src={{ ib_repo_file_path }} dest={{ local_working_dir }}/gating_repo.tar.gz flat=yes"
      delegate_to: "{{ ib_repo_host }}"

    - name: Upload repo to host for install
      copy: "src={{ local_working_dir }}/gating_repo.tar.gz dest=/tmp/gating_repo.tar.gz"

- name: Copy compressed repo to /tmp
  shell: cp -f {{ ib_repo_file_path }} /tmp/gating_repo.tar.gz
  when: ib_repo_host is not defined

- include: install_built_repo.yml
  when: ib_repo_run_live|bool

- include: inject_repo.yml
  when: ib_repo_image_inject|bool
