post_control_plane.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', openshift_image_tag ) }}"
  9. router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', openshift_image_tag ) }}"
  10. oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig"
  11. pre_tasks:
  12. - name: Load lib_openshift modules
  13. include_role:
  14. name: lib_openshift
  15. - name: Collect all routers
  16. oc_obj:
  17. state: list
  18. kind: pods
  19. all_namespaces: True
  20. selector: 'router'
  21. register: all_routers
  22. - set_fact: haproxy_routers="{{ all_routers.results.results[0]['items'] | oo_pods_match_component(openshift_deployment_type, 'haproxy-router') | oo_select_keys_from_list(['metadata']) }}"
  23. when:
  24. - all_routers.results.returncode == 0
  25. - set_fact: haproxy_routers=[]
  26. when:
  27. - all_routers.results.returncode != 0
  28. - name: Update router image to current version
  29. when:
  30. - all_routers.results.returncode == 0
  31. command: >
  32. {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -n {{ item['namespace'] }} -p
  33. '{"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}}]}}}}'
  34. --api-version=v1
  35. with_items: "{{ haproxy_routers }}"
  36. # AUDIT:changed_when_note: `false` not being set here. What we
  37. # need to do is check the current router image version and see if
  38. # this task needs to be ran.
  39. - name: Check for default registry
  40. oc_obj:
  41. state: list
  42. kind: dc
  43. name: docker-registry
  44. register: _default_registry
  45. - name: Update registry image to current version
  46. when:
  47. - _default_registry.results.results[0] != {}
  48. command: >
  49. {{ oc_cmd }} patch dc/docker-registry -n default -p
  50. '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}'
  51. --api-version=v1
  52. # AUDIT:changed_when_note: `false` not being set here. What we
  53. # need to do is check the current registry image version and see
  54. # if this task needs to be ran.
  55. roles:
  56. - openshift_manageiq
  57. # Create the new templates shipped in 3.2, existing templates are left
  58. # unmodified. This prevents the subsequent role definition for
  59. # openshift_examples from failing when trying to replace templates that do
  60. # not already exist. We could have potentially done a replace --force to
  61. # create and update in one step.
  62. - openshift_examples
  63. - openshift_hosted_templates
  64. # Update the existing templates
  65. - role: openshift_examples
  66. registry_url: "{{ openshift.master.registry_url }}"
  67. openshift_examples_import_command: replace
  68. - role: openshift_hosted_templates
  69. registry_url: "{{ openshift.master.registry_url }}"
  70. openshift_hosted_templates_import_command: replace
  71. # Check for warnings to be printed at the end of the upgrade:
  72. - name: Check for warnings
  73. hosts: oo_masters_to_config
  74. tasks:
  75. # Check if any masters are using pluginOrderOverride and warn if so, only for 1.3/3.3 and beyond:
  76. - name: grep pluginOrderOverride
  77. command: grep pluginOrderOverride {{ openshift.common.config_base }}/master/master-config.yaml
  78. register: grep_plugin_order_override
  79. when: openshift.common.version_gte_3_3_or_1_3 | bool
  80. changed_when: false
  81. failed_when: false
  82. - name: Warn if pluginOrderOverride is in use in master-config.yaml
  83. debug:
  84. 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."
  85. when:
  86. - not grep_plugin_order_override | skipped
  87. - grep_plugin_order_override.rc == 0
  88. - include: ../reset_excluder.yml
  89. tags:
  90. - always