upgrade.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ---
  2. - name: Stop control plane services
  3. service:
  4. name: "{{ item }}"
  5. state: stopped
  6. with_items:
  7. - "{{ openshift_service_type }}-master-api"
  8. - "{{ openshift_service_type }}-master-controllers"
  9. failed_when: false
  10. # Only needed for 3.10, remove in 3.11.
  11. - import_tasks: migrate_idproviders.yml
  12. - import_tasks: static_shim.yml
  13. - import_tasks: upgrade/upgrade_scheduler.yml
  14. # master_config_hook is passed in from upgrade play.
  15. - include_tasks: "upgrade/{{ master_config_hook }}"
  16. when: master_config_hook is defined
  17. - import_tasks: set_loopback_context.yml
  18. - name: Check for ca-bundle.crt
  19. stat:
  20. path: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
  21. register: ca_bundle_stat
  22. failed_when: false
  23. - name: Check for ca.crt
  24. stat:
  25. path: "{{ openshift.common.config_base }}/master/ca.crt"
  26. register: ca_crt_stat
  27. failed_when: false
  28. - name: Migrate ca.crt to ca-bundle.crt
  29. command: mv ca.crt ca-bundle.crt
  30. args:
  31. chdir: "{{ openshift.common.config_base }}/master"
  32. when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists
  33. - name: Link ca.crt to ca-bundle.crt
  34. file:
  35. src: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
  36. path: "{{ openshift.common.config_base }}/master/ca.crt"
  37. state: link
  38. when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists
  39. - name: Find existing master sysconfig
  40. find:
  41. paths:
  42. - /etc/sysconfig
  43. patterns:
  44. - openshift-master-api
  45. - openshift-master-controllers
  46. - origin-master-api
  47. - origin-master-controllers
  48. register: sysconfigs
  49. - when:
  50. - sysconfigs is succeeded
  51. - sysconfigs.matched > 0
  52. name: Migrate OPENSHIFT_DEFAULT_REGISTRY from master sysconfig to master-config.yaml
  53. block:
  54. - name: Get master sysconfig contents
  55. slurp:
  56. src: "{{ sysconfigs.files[0].path }}"
  57. register: sysconfig
  58. # TODO: surely there is a better way
  59. - name: Update imagePolicyConfig.internalRegistryHostname
  60. yedit:
  61. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  62. key: "imagePolicyConfig.internalRegistryHostname"
  63. value: "{{ item | regex_replace('^OPENSHIFT_DEFAULT_REGISTRY=\\s*([^#\\s]+).*','\\1') }}"
  64. with_items: "{{ (sysconfig.content | b64decode).split('\n') | select('match','^OPENSHIFT_DEFAULT_REGISTRY=\\s*.+') | list }}"
  65. # TODO(michaelgugino): Remove in 3.11
  66. - name: Add new network config section to master conf
  67. yedit:
  68. src: /etc/origin/master/master-config.yml
  69. key: networkConfig.clusterNetworks
  70. value: "{{ l_new_config_clusterNetworks }}"
  71. # l_existing_config_master_config is set via playbooks/init/basic_facts.yml
  72. when: l_existing_config_master_config.networkConfig.clusterNetworks is not defined
  73. # TODO(michaelgugino): Remove in 3.11
  74. - name: Remove old network config section in master conf
  75. yedit:
  76. src: /etc/origin/master/master-config.yaml
  77. key: "{{ item }}"
  78. state: absent
  79. with_items:
  80. - networkConfig.clusterNetworkCIDR
  81. - networkConfig.hostSubnetLength
  82. - name: Create the master service env file if it does not exist
  83. template:
  84. src: "master.env.j2"
  85. dest: "{{ openshift.common.config_base }}/master/master.env"
  86. force: no
  87. - name: Update oreg value
  88. yedit:
  89. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  90. key: 'imageConfig.format'
  91. value: "{{ oreg_url | default(oreg_url_master) }}"
  92. when: oreg_url is defined or oreg_url_master is defined
  93. - name: Change default node selector to compute=true
  94. yedit:
  95. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  96. key: 'projectConfig.defaultNodeSelector'
  97. value: '{{ hostvars[groups.oo_first_master.0].l_osm_default_node_selector }}'
  98. when: openshift_upgrade_target is version_compare('3.9', '>=')
  99. - name: Remove use of pod presets from master config
  100. yedit:
  101. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  102. key: 'admissionConfig.pluginConfig.PodPreset'
  103. state: absent
  104. - name: Find current value for runtime-config
  105. yedit:
  106. src: "/tmp/master-config.yaml"
  107. key: "kubernetesMasterConfig.apiServerArguments.runtime-config"
  108. state: list
  109. register: runtime_config
  110. - name: Set the runtime-config to exclude pod presets
  111. yedit:
  112. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  113. key: "kubernetesMasterConfig.apiServerArguments.runtime-config"
  114. value: "{{ runtime_config.result | join(',') | regex_replace('(?:,)*apis/settings\\.k8s\\.io/v1alpha1=true','') }}"
  115. when: runtime_config.result
  116. - name: Remove old service information
  117. file:
  118. path: "{{ item }}"
  119. state: absent
  120. with_items:
  121. - /etc/systemd/system/atomic-openshift-master-api.service
  122. - /etc/systemd/system/atomic-openshift-master-controllers.service
  123. - /etc/systemd/system/origin-master-api.service
  124. - /etc/systemd/system/origin-master-controllers.service
  125. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  126. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  127. - /usr/lib/systemd/system/origin-master-api.service
  128. - /usr/lib/systemd/system/origin-master-controllers.service
  129. - name: reload systemd units
  130. command: systemctl daemon-reload