verify_cluster.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ---
  2. # Verify a few items before we proceed with upgrade process.
  3. - name: Verify upgrade can proceed on first master
  4. hosts: oo_first_master
  5. gather_facts: no
  6. tasks:
  7. # Error out in situations where the user has older versions specified in their
  8. # inventory in any of the openshift_release, openshift_image_tag, and
  9. # openshift_pkg_version variables. These must be removed or updated to proceed
  10. # with upgrade.
  11. # TODO: Should we block if you're *over* the next major release version as well?
  12. - fail:
  13. msg: >
  14. openshift_pkg_version is {{ openshift_pkg_version }} which is not a
  15. valid version for a {{ openshift_upgrade_target }} upgrade
  16. when:
  17. - openshift_pkg_version is defined
  18. - openshift_pkg_version != ""
  19. - openshift_pkg_version.split('-',1).1 is version_compare(openshift_upgrade_target ,'<')
  20. - fail:
  21. msg: >
  22. openshift_image_tag is {{ openshift_image_tag }} which is not a
  23. valid version for a {{ openshift_upgrade_target }} upgrade
  24. when:
  25. - openshift_image_tag is defined
  26. - openshift_image_tag != ""
  27. - openshift_image_tag.split('v',1).1 is version_compare(openshift_upgrade_target ,'<')
  28. - set_fact:
  29. openshift_release: "{{ openshift_release[1:] }}"
  30. when: openshift_release is defined and openshift_release[0] == 'v'
  31. - fail:
  32. msg: >
  33. openshift_release is {{ openshift_release }} which is not a
  34. valid release for a {{ openshift_upgrade_target }} upgrade
  35. when:
  36. - openshift_release is defined
  37. - not (openshift_release is version_compare(openshift_upgrade_target ,'='))
  38. # Ensure glusterfs clusters are healthy before starting an upgrade.
  39. - import_role:
  40. name: openshift_storage_glusterfs
  41. tasks_from: check_cluster_health.yml
  42. when: >
  43. "'glusterfs' in groups" and "groups['glusterfs'] | length > 0"
  44. or "'glusterfs_registry' in groups" and "groups['glusterfs_registry'] | length > 0"
  45. - name: Verify master processes
  46. hosts: oo_masters_to_config
  47. roles:
  48. - lib_utils
  49. - openshift_facts
  50. tasks:
  51. - name: Read master storage backend setting
  52. yedit:
  53. state: list
  54. src: /etc/origin/master/master-config.yaml
  55. key: kubernetesMasterConfig.apiServerArguments.storage-backend
  56. register: _storage_backend
  57. - fail:
  58. msg: "The cluster must be migrated to etcd v3 prior to upgrading to 3.7. Please see https://docs.openshift.com/container-platform/3.7/install_config/upgrading/migrating_etcd.html"
  59. when:
  60. # assuming the master-config.yml is properly configured, i.e. the value is a list
  61. - _storage_backend.result | default([], true) | length == 0 or _storage_backend.result[0] != "etcd3"
  62. - debug:
  63. msg: "Storage backend is set to etcd3"
  64. - openshift_facts:
  65. role: master
  66. local_facts:
  67. ha: "{{ groups.oo_masters_to_config | length > 1 }}"
  68. - when:
  69. - openshift_is_containerized | bool
  70. - not openshift_is_bootstrapped | bool
  71. block:
  72. - set_fact:
  73. master_services:
  74. - "{{ openshift_service_type }}-master"
  75. # In case of the non-ha to ha upgrade.
  76. - name: Check if the {{ openshift_service_type }}-master-api.service exists
  77. command: >
  78. systemctl list-units {{ openshift_service_type }}-master-api.service --no-legend
  79. register: master_api_service_status
  80. - set_fact:
  81. master_services:
  82. - "{{ openshift_service_type }}-master-api"
  83. - "{{ openshift_service_type }}-master-controllers"
  84. when:
  85. - master_api_service_status.stdout_lines | length > 0
  86. - (openshift_service_type + '-master-api.service') in master_api_service_status.stdout_lines[0]
  87. - name: Ensure Master is running
  88. service:
  89. name: "{{ item }}"
  90. state: started
  91. enabled: yes
  92. with_items: "{{ master_services }}"