upgrade.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ---
  2. - name: Evaluate groups
  3. include: ../../evaluate_groups.yml
  4. - name: Re-Run cluster configuration to apply latest configuration changes
  5. include: ../../config.yml
  6. - name: Upgrade masters
  7. hosts: oo_masters_to_config
  8. vars:
  9. openshift_version: "{{ openshift_pkg_version | default('') }}"
  10. tasks:
  11. - name: Upgrade master packages
  12. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version }} state=latest"
  13. - name: Restart master services
  14. service: name="{{ openshift.common.service_type}}-master" state=restarted
  15. - name: Upgrade nodes
  16. hosts: oo_nodes_to_config
  17. vars:
  18. openshift_version: "{{ openshift_pkg_version | default('') }}"
  19. tasks:
  20. - name: Upgrade node packages
  21. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }} state=latest"
  22. - name: Restart node services
  23. service: name="{{ openshift.common.service_type }}-node" state=restarted
  24. - name: Determine new master version
  25. hosts: oo_first_master
  26. tasks:
  27. - name: Determine new version
  28. command: >
  29. rpm -q --queryformat '%{version}' {{ openshift.common.service_type }}-master
  30. register: _new_version
  31. - name: Ensure AOS 3.0.2 or Origin 1.0.6
  32. hosts: oo_first_master
  33. tasks:
  34. fail: This playbook requires Origin 1.0.6 or Atomic OpenShift 3.0.2 or later
  35. when: _new_version.stdout | version_compare('1.0.6','<') or ( _new_version.stdout | version_compare('3.0','>=' and _new_version.stdout | version_compare('3.0.2','<') )
  36. - name: Update cluster policy
  37. hosts: oo_first_master
  38. tasks:
  39. - name: oadm policy reconcile-cluster-roles --confirm
  40. command: >
  41. {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  42. policy reconcile-cluster-roles --confirm
  43. - name: Upgrade default router
  44. hosts: oo_first_master
  45. vars:
  46. - router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', 'v' + _new_version.stdout ) }}"
  47. - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig"
  48. tasks:
  49. - name: Check for default router
  50. command: >
  51. {{ oc_cmd }} get -n default dc/router
  52. register: _default_router
  53. failed_when: false
  54. changed_when: false
  55. - name: Check for allowHostNetwork and allowHostPorts
  56. when: _default_router.rc == 0
  57. shell: >
  58. {{ oc_cmd }} get -o yaml scc/privileged | /usr/bin/grep -e allowHostPorts -e allowHostNetwork
  59. register: _scc
  60. - name: Grant allowHostNetwork and allowHostPorts
  61. when:
  62. - _default_router.rc == 0
  63. - "'false' in _scc.stdout"
  64. command: >
  65. {{ oc_cmd }} patch scc/privileged -p '{"allowHostPorts":true,"allowHostNetwork":true}' --loglevel=9
  66. - name: Update deployment config to 1.0.4/3.0.1 spec
  67. when: _default_router.rc == 0
  68. command: >
  69. {{ oc_cmd }} patch dc/router -p
  70. '{"spec":{"strategy":{"rollingParams":{"updatePercent":-10},"spec":{"serviceAccount":"router","serviceAccountName":"router"}}}}'
  71. - name: Switch to hostNetwork=true
  72. when: _default_router.rc == 0
  73. command: >
  74. {{ oc_cmd }} patch dc/router -p '{"spec":{"template":{"spec":{"hostNetwork":true}}}}'
  75. - name: Update router image to current version
  76. when: _default_router.rc == 0
  77. command: >
  78. {{ oc_cmd }} patch dc/router -p
  79. '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}"}]}}}}'
  80. - name: Upgrade default
  81. hosts: oo_first_master
  82. vars:
  83. - registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', 'v' + _new_version.stdout ) }}"
  84. - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig"
  85. tasks:
  86. - name: Check for default registry
  87. command: >
  88. {{ oc_cmd }} get -n default dc/docker-registry
  89. register: _default_registry
  90. failed_when: false
  91. changed_when: false
  92. - name: Update registry image to current version
  93. when: _default_registry.rc == 0
  94. command: >
  95. {{ oc_cmd }} patch dc/docker-registry -p
  96. '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}'
  97. - name: Update image streams and templates
  98. hosts: oo_first_master
  99. vars:
  100. openshift_examples_import_command: "update"
  101. openshift_deployment_type: "{{ deployment_type }}"
  102. roles:
  103. - openshift_examples