post_control_plane.yml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ---
  2. ###############################################################################
  3. # Post upgrade - Upgrade default router, default registry and examples
  4. ###############################################################################
  5. - name: Upgrade default router and default registry
  6. hosts: oo_first_master
  7. vars:
  8. openshift_deployment_type: "{{ deployment_type }}"
  9. registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', openshift_image_tag ) }}"
  10. router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', openshift_image_tag ) }}"
  11. oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig"
  12. roles:
  13. - openshift_manageiq
  14. # Create the new templates shipped in 3.2, existing templates are left
  15. # unmodified. This prevents the subsequent role definition for
  16. # openshift_examples from failing when trying to replace templates that do
  17. # not already exist. We could have potentially done a replace --force to
  18. # create and update in one step.
  19. - openshift_examples
  20. - openshift_hosted_templates
  21. # Update the existing templates
  22. - role: openshift_examples
  23. registry_url: "{{ openshift.master.registry_url }}"
  24. openshift_examples_import_command: replace
  25. - role: openshift_hosted_templates
  26. registry_url: "{{ openshift.master.registry_url }}"
  27. openshift_hosted_templates_import_command: replace
  28. pre_tasks:
  29. - name: Collect all routers
  30. command: >
  31. {{ oc_cmd }} get pods --all-namespaces -l 'router' -o json
  32. register: all_routers
  33. failed_when: false
  34. changed_when: false
  35. - set_fact: haproxy_routers="{{ (all_routers.stdout | from_json)['items'] | oo_pods_match_component(openshift_deployment_type, 'haproxy-router') | oo_select_keys_from_list(['metadata']) }}"
  36. when: all_routers.rc == 0
  37. - set_fact: haproxy_routers=[]
  38. when: all_routers.rc != 0
  39. - name: Update router image to current version
  40. when: all_routers.rc == 0
  41. command: >
  42. {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -n {{ item['namespace'] }} -p
  43. '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}","livenessProbe":{"tcpSocket":null,"httpGet":{"path": "/healthz", "port": 1936, "host": "localhost", "scheme": "HTTP"},"initialDelaySeconds":10,"timeoutSeconds":1}}]}}}}'
  44. --api-version=v1
  45. with_items: "{{ haproxy_routers }}"
  46. - name: Check for default registry
  47. command: >
  48. {{ oc_cmd }} get -n default dc/docker-registry
  49. register: _default_registry
  50. failed_when: false
  51. changed_when: false
  52. - name: Update registry image to current version
  53. when: _default_registry.rc == 0
  54. command: >
  55. {{ oc_cmd }} patch dc/docker-registry -n default -p
  56. '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}'
  57. --api-version=v1
  58. # Check for warnings to be printed at the end of the upgrade:
  59. - name: Check for warnings
  60. hosts: oo_masters_to_config
  61. tasks:
  62. # Check if any masters are using pluginOrderOverride and warn if so, only for 1.3/3.3 and beyond:
  63. - command: >
  64. grep pluginOrderOverride {{ openshift.common.config_base }}/master/master-config.yaml
  65. register: grep_plugin_order_override
  66. when: openshift.common.version_gte_3_3_or_1_3 | bool
  67. failed_when: false
  68. - name: Warn if pluginOrderOverride is in use in master-config.yaml
  69. debug: msg="WARNING pluginOrderOverride is being deprecated in master-config.yaml, please see https://docs.openshift.com/enterprise/latest/architecture/additional_concepts/admission_controllers.html for more information."
  70. when: not grep_plugin_order_override | skipped and grep_plugin_order_override.rc == 0