---
- include_tasks: upgrade/rpm_upgrade.yml
  when: not openshift_is_containerized | bool

- include_tasks: upgrade/upgrade_scheduler.yml

# master_config_hook is passed in from upgrade play.
- include_tasks: "upgrade/{{ master_config_hook }}"
  when: master_config_hook is defined

- include_tasks: systemd_units.yml

- name: Check for ca-bundle.crt
  stat:
    path: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
    get_checksum: false
    get_attributes: false
    get_mime: false
  register: ca_bundle_stat
  failed_when: false

- name: Check for ca.crt
  stat:
    path: "{{ openshift.common.config_base }}/master/ca.crt"
    get_checksum: false
    get_attributes: false
    get_mime: false
  register: ca_crt_stat
  failed_when: false

- name: Migrate ca.crt to ca-bundle.crt
  command: mv ca.crt ca-bundle.crt
  args:
    chdir: "{{ openshift.common.config_base }}/master"
  when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists

- name: Link ca.crt to ca-bundle.crt
  file:
    src: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
    path: "{{ openshift.common.config_base }}/master/ca.crt"
    state: link
    force: yes
  when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists

- name: Update oreg value
  yedit:
    src: "{{ openshift.common.config_base }}/master/master-config.yaml"
    key: 'imageConfig.format'
    value: "{{ oreg_url | default(oreg_url_master) }}"
  when: oreg_url is defined or oreg_url_master is defined

- name: Change default node selector to compute=true
  yedit:
    src: "{{ openshift.common.config_base }}/master/master-config.yaml"
    key: 'projectConfig.defaultNodeSelector'
    value: '{{ hostvars[groups.oo_first_master.0].l_osm_default_node_selector }}'
  when: openshift_upgrade_target | version_compare('3.9', '>=')
