post_control_plane.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. # Update the existing templates
  21. - role: openshift_examples
  22. registry_url: "{{ openshift.master.registry_url }}"
  23. openshift_examples_import_command: replace
  24. pre_tasks:
  25. - name: Collect all routers
  26. command: >
  27. {{ oc_cmd }} get pods --all-namespaces -l 'router' -o json
  28. register: all_routers
  29. failed_when: false
  30. changed_when: false
  31. - 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']) }}"
  32. when: all_routers.rc == 0
  33. - set_fact: haproxy_routers=[]
  34. when: all_routers.rc != 0
  35. - name: Update router image to current version
  36. when: all_routers.rc == 0
  37. command: >
  38. {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -n {{ item['namespace'] }} -p
  39. '{"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}}]}}}}'
  40. --api-version=v1
  41. with_items: "{{ haproxy_routers }}"
  42. - name: Check for default registry
  43. command: >
  44. {{ oc_cmd }} get -n default dc/docker-registry
  45. register: _default_registry
  46. failed_when: false
  47. changed_when: false
  48. - name: Update registry image to current version
  49. when: _default_registry.rc == 0
  50. command: >
  51. {{ oc_cmd }} patch dc/docker-registry -n default -p
  52. '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}'
  53. --api-version=v1
  54. # Check for warnings to be printed at the end of the upgrade:
  55. - name: Check for warnings
  56. hosts: oo_masters_to_config
  57. tasks:
  58. # Check if any masters are using pluginOrderOverride and warn if so, only for 1.3/3.3 and beyond:
  59. - command: >
  60. grep pluginOrderOverride {{ openshift.common.config_base }}/master/master-config.yaml
  61. register: grep_plugin_order_override
  62. when: openshift.common.version_gte_3_3_or_1_3 | bool
  63. failed_when: false
  64. - name: Warn if pluginOrderOverride is in use in master-config.yaml
  65. 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."
  66. when: not grep_plugin_order_override | skipped and grep_plugin_order_override.rc == 0