verify_cluster.yml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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(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(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(openshift_upgrade_target ,'='))
  38. - name: Verify master processes
  39. hosts: oo_masters_to_config
  40. roles:
  41. - lib_utils
  42. - openshift_facts
  43. tasks:
  44. - name: Read master storage backend setting
  45. yedit:
  46. state: list
  47. src: /etc/origin/master/master-config.yaml
  48. key: kubernetesMasterConfig.apiServerArguments.storage-backend
  49. register: _storage_backend
  50. - fail:
  51. 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"
  52. when:
  53. # assuming the master-config.yml is properly configured, i.e. the value is a list
  54. - _storage_backend.result | default([], true) | length == 0 or _storage_backend.result[0] != "etcd3"
  55. - debug:
  56. msg: "Storage backend is set to etcd3"
  57. - openshift_facts:
  58. role: master
  59. local_facts:
  60. ha: "{{ groups.oo_masters_to_config | length > 1 }}"
  61. - when:
  62. - openshift_is_containerized | bool
  63. - not openshift_is_bootstrapped | bool
  64. block:
  65. - set_fact:
  66. master_services:
  67. - "{{ openshift_service_type }}-master"
  68. # In case of the non-ha to ha upgrade.
  69. - name: Check if the {{ openshift_service_type }}-master-api.service exists
  70. command: >
  71. systemctl list-units {{ openshift_service_type }}-master-api.service --no-legend
  72. register: master_api_service_status
  73. - set_fact:
  74. master_services:
  75. - "{{ openshift_service_type }}-master-api"
  76. - "{{ openshift_service_type }}-master-controllers"
  77. when:
  78. - master_api_service_status.stdout_lines | length > 0
  79. - (openshift_service_type + '-master-api.service') in master_api_service_status.stdout_lines[0]
  80. - name: Ensure Master is running
  81. service:
  82. name: "{{ item }}"
  83. state: started
  84. enabled: yes
  85. with_items: "{{ master_services }}"