upgrade.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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: sysconfigs|succeeded and sysconfigs.matched > 0
  50. name: Migrate OPENSHIFT_DEFAULT_REGISTRY from master sysconfig to master-config.yaml
  51. block:
  52. - name: Get master sysconfig contents
  53. slurp:
  54. src: "{{ sysconfigs.files[0].path }}"
  55. register: sysconfig
  56. # TODO: surely there is a better way
  57. - name: Update imagePolicyConfig.internalRegistryHostname
  58. yedit:
  59. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  60. key: "imagePolicyConfig.internalRegistryHostname"
  61. value: "{{ item | regex_replace('^OPENSHIFT_DEFAULT_REGISTRY=\\s*([^#\\s]+).*','\\1') }}"
  62. with_items: "{{ (sysconfig.content | b64decode).split('\n') | select('match','^OPENSHIFT_DEFAULT_REGISTRY=\\s*.+') | list }}"
  63. - name: Create the master service env file if it does not exist
  64. template:
  65. src: "master.env.j2"
  66. dest: "{{ openshift.common.config_base }}/master/master.env"
  67. force: no
  68. - name: Update oreg value
  69. yedit:
  70. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  71. key: 'imageConfig.format'
  72. value: "{{ oreg_url | default(oreg_url_master) }}"
  73. when: oreg_url is defined or oreg_url_master is defined
  74. - name: Change default node selector to compute=true
  75. yedit:
  76. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  77. key: 'projectConfig.defaultNodeSelector'
  78. value: '{{ hostvars[groups.oo_first_master.0].l_osm_default_node_selector }}'
  79. when: openshift_upgrade_target | version_compare('3.9', '>=')
  80. - name: Remove use of pod presets from master config
  81. yedit:
  82. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  83. key: 'admissionConfig.pluginConfig.PodPreset'
  84. state: absent
  85. - name: Find current value for runtime-config
  86. yedit:
  87. src: "/tmp/master-config.yaml"
  88. key: "kubernetesMasterConfig.apiServerArguments.runtime-config"
  89. state: list
  90. register: runtime_config
  91. - name: Set the runtime-config to exclude pod presets
  92. yedit:
  93. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  94. key: "kubernetesMasterConfig.apiServerArguments.runtime-config"
  95. value: "{{ runtime_config.result | join(',') | regex_replace('(?:,)*apis/settings\\.k8s\\.io/v1alpha1=true','') }}"
  96. when: runtime_config.result
  97. - name: Remove old service information
  98. file:
  99. path: "{{ item }}"
  100. state: absent
  101. with_items:
  102. - /etc/systemd/system/atomic-openshift-master-api.service
  103. - /etc/systemd/system/atomic-openshift-master-controllers.service
  104. - /etc/systemd/system/origin-master-api.service
  105. - /etc/systemd/system/origin-master-controllers.service
  106. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  107. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  108. - /usr/lib/systemd/system/origin-master-api.service
  109. - /usr/lib/systemd/system/origin-master-controllers.service
  110. - name: reload systemd units
  111. command: systemctl daemon-reload