verify_upgrade_targets.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - name: Verify upgrade targets
  3. hosts: oo_masters_to_config:oo_nodes_to_upgrade
  4. vars:
  5. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  6. pre_tasks:
  7. - fail:
  8. msg: Verify OpenShift is already installed
  9. when: openshift.common.version is not defined
  10. - fail:
  11. msg: Verify the correct version was found
  12. when: verify_upgrade_version is defined and openshift_version != verify_upgrade_version
  13. - name: Clean package cache
  14. command: "{{ ansible_pkg_mgr }} clean all"
  15. when: not openshift.common.is_atomic | bool
  16. - set_fact:
  17. g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}"
  18. when: not openshift.common.is_containerized | bool
  19. - name: Verify containers are available for upgrade
  20. command: >
  21. docker pull {{ openshift.common.cli_image }}:{{ openshift_image_tag }}
  22. register: pull_result
  23. changed_when: "'Downloaded newer image' in pull_result.stdout"
  24. when: openshift.common.is_containerized | bool
  25. - name: Check latest available OpenShift RPM version
  26. command: >
  27. {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type }}"
  28. failed_when: false
  29. changed_when: false
  30. register: avail_openshift_version
  31. when: not openshift.common.is_containerized | bool
  32. - name: Verify OpenShift RPMs are available for upgrade
  33. fail:
  34. msg: "OpenShift {{ avail_openshift_version.stdout }} is available, but {{ openshift_upgrade_target }} or greater is required"
  35. when: not openshift.common.is_containerized | bool and not avail_openshift_version | skipped and avail_openshift_version.stdout | default('0.0', True) | version_compare(openshift_release, '<')
  36. - fail:
  37. msg: "This upgrade playbook must be run against OpenShift {{ openshift_upgrade_min }} or later"
  38. when: deployment_type == 'origin' and openshift.common.version | version_compare(openshift_upgrade_min,'<')