---
# input variables:
# - openshift_service_type
# - component
# - openshift_pkg_version
# - openshift_is_atomic

# When we update package "a-${version}" and a requires b >= ${version} if we
# don't specify the version of b yum will choose the latest version of b
# available and the whole set of dependencies end up at the latest version.
# Since the package module, unlike the yum module, doesn't flatten a list
# of packages into one transaction we need to do that explicitly. The ansible
# core team tells us not to rely on yum module transaction flattening anyway.

# Pre-pull new node rpm, but don't install
- name: download new node packages
  command: "{{ ansible_pkg_mgr }} install -y --downloadonly {{ openshift_node_upgrade_rpm_list | join(' ')}}"
  register: result
  until: result is succeeded
  vars:
    openshift_node_upgrade_rpm_list:
      - "{{ openshift_service_type }}{{ openshift_pkg_version | default('') }}"
      - "{{ openshift_service_type }}-node{{ openshift_pkg_version | default('') }}"
      - "{{ openshift_service_type + '-sdn-ovs' + openshift_pkg_version | default('') if openshift_use_openshift_sdn | default(true) | bool else '' }}"
      - "{{ openshift_service_type }}-clients{{ openshift_pkg_version | default('') }}"
      - "PyYAML"
      - "dnsmasq"

# Pre-pull the rpms for openvswitch, but don't install
# openvswitch requires the latest version to be installed.
- name: download openvswitch upgrade rpm
  command: "{{ ansible_pkg_mgr }} update -y --downloadonly openvswitch"
  register: result
  until: result is succeeded
  when: openshift_use_openshift_sdn | bool
