---
# This is a hack to allow us to update various components without restarting
# services.  This will persist into the upgrade play as well, so everything
# needs to be restarted by hand.
- set_fact:
    skip_node_svc_handlers: True

- import_tasks: registry_auth.yml

- name: update package meta data to speed install later.
  command: "{{ ansible_pkg_mgr }} makecache"
  register: result
  until: result is succeeded
  when: not openshift_is_atomic | bool

- name: Check Docker image count
  shell: "docker images -aq | wc -l"
  register: docker_image_count
  when:
  - l_docker_upgrade is defined
  - l_docker_upgrade | bool

- debug: var=docker_image_count.stdout
  when:
  - l_docker_upgrade is defined
  - l_docker_upgrade | bool

# Prepull the rpms for docker upgrade, but don't install
- name: download docker upgrade rpm
  command: "{{ ansible_pkg_mgr }} install -y --downloadonly docker{{ '-' + docker_version }}"
  register: result
  until: result is succeeded
  when:
  - l_docker_upgrade is defined
  - l_docker_upgrade | bool

- name: Stage cri-o updates
  command: "{{ ansible_pkg_mgr }} install -y --downloadonly {{ crio_pkgs | join(' ') }}"
  register: result
  until: result is succeeded
  when:
  - openshift_use_crio | default(False)
  vars:
    crio_pkgs:
    - "cri-o"
    - "cri-tools"

- import_tasks: upgrade/rpm_upgrade.yml
  when: not openshift_is_atomic | bool
