---
- name: Install node, clients, and conntrack packages
  package:
    name: "{{ pkg_list | join(',') }}"
    state: present
  register: result
  until: result is succeeded
  vars:
    pkg_list:
    - "{{ openshift_service_type }}{{ (openshift_pkg_version | default('')) | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
    - "{{ openshift_service_type }}-hyperkube{{ (openshift_pkg_version | default('')) | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
    - "{{ openshift_service_type }}-node{{ (openshift_pkg_version | default('')) | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
    - "{{ openshift_service_type }}-clients{{ (openshift_pkg_version | default('')) | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
    - conntrack-tools
  when:
  - not openshift_is_atomic | bool

- when: openshift_is_atomic | bool
  block:
  - name: Pull CLI Image (docker)
    docker_image:
      name: "{{ openshift_cli_image }}"
    when: not openshift_use_crio_only | bool

  - name: Pull CLI Image (atomic)
    command: >
      atomic pull --storage ostree {{ system_openshift_cli_image }}
    register: pull_result
    changed_when: "'Pulling layer' in pull_result.stdout"
    when: openshift_use_crio_only | bool

  # openshift_container_binary_sync is a custom module in lib_utils
  - name: Copy client binaries/symlinks out of CLI image for use on the host
    openshift_container_binary_sync:
      image: "{{ openshift_cli_image }}"
      backend: "{{ (openshift_use_crio_only | bool) | ternary('atomic', 'docker') }}"
