You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
6.4 KiB

6 years ago
  1. ---
  2. - hosts: localhost
  3. gather_facts: false
  4. become: no
  5. tasks:
  6. - name: "Check ansible version >=2.7.8"
  7. assert:
  8. msg: "Ansible must be v2.7.8 or higher"
  9. that:
  10. - ansible_version.string is version("2.7.8", ">=")
  11. tags:
  12. - check
  13. vars:
  14. ansible_connection: local
  15. - hosts: all
  16. gather_facts: false
  17. tasks:
  18. - name: "Set up proxy environment"
  19. set_fact:
  20. proxy_env:
  21. http_proxy: "{{ http_proxy | default ('') }}"
  22. HTTP_PROXY: "{{ http_proxy | default ('') }}"
  23. https_proxy: "{{ https_proxy | default ('') }}"
  24. HTTPS_PROXY: "{{ https_proxy | default ('') }}"
  25. no_proxy: "{{ no_proxy | default ('') }}"
  26. NO_PROXY: "{{ no_proxy | default ('') }}"
  27. no_log: true
  28. - hosts: bastion[0]
  29. gather_facts: False
  30. roles:
  31. - { role: kubespray-defaults }
  32. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  33. - hosts: k8s-cluster:etcd:calico-rr
  34. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  35. gather_facts: false
  36. vars:
  37. # Need to disable pipelining for bootstrap-os as some systems have requiretty in sudoers set, which makes pipelining
  38. # fail. bootstrap-os fixes this on these systems, so in later plays it can be enabled.
  39. ansible_ssh_pipelining: false
  40. roles:
  41. - { role: kubespray-defaults }
  42. - { role: bootstrap-os, tags: bootstrap-os}
  43. - name: Gather facts
  44. import_playbook: facts.yml
  45. - name: Download images to ansible host cache via first kube-master node
  46. hosts: kube-master[0]
  47. gather_facts: False
  48. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  49. roles:
  50. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost"}
  51. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  52. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  53. environment: "{{ proxy_env }}"
  54. - name: Prepare nodes for upgrade
  55. hosts: k8s-cluster:etcd:calico-rr
  56. gather_facts: False
  57. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  58. roles:
  59. - { role: kubespray-defaults }
  60. - { role: kubernetes/preinstall, tags: preinstall }
  61. - { role: download, tags: download, when: "not skip_downloads" }
  62. environment: "{{ proxy_env }}"
  63. - name: Upgrade container engine on non-cluster nodes
  64. hosts: etcd:calico-rr:!k8s-cluster
  65. gather_facts: False
  66. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  67. serial: "{{ serial | default('20%') }}"
  68. roles:
  69. - { role: kubespray-defaults }
  70. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  71. environment: "{{ proxy_env }}"
  72. - hosts: etcd
  73. gather_facts: False
  74. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  75. roles:
  76. - { role: kubespray-defaults }
  77. - role: etcd
  78. tags: etcd
  79. vars:
  80. etcd_cluster_setup: true
  81. etcd_events_cluster_setup: false
  82. when: not etcd_kubeadm_enabled | default(false)
  83. - hosts: k8s-cluster
  84. gather_facts: False
  85. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  86. roles:
  87. - { role: kubespray-defaults }
  88. - role: etcd
  89. tags: etcd
  90. vars:
  91. etcd_cluster_setup: false
  92. etcd_events_cluster_setup: false
  93. when: not etcd_kubeadm_enabled | default(false)
  94. - name: Handle upgrades to master components first to maintain backwards compat.
  95. gather_facts: False
  96. hosts: kube-master
  97. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  98. serial: 1
  99. roles:
  100. - { role: kubespray-defaults }
  101. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  102. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  103. - { role: kubernetes/node, tags: node }
  104. - { role: kubernetes/master, tags: master, upgrade_cluster_setup: true }
  105. - { role: kubernetes/client, tags: client }
  106. - { role: kubernetes/node-label, tags: node-label }
  107. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  108. - { role: kubernetes-apps, tags: csi-driver }
  109. - { role: upgrade/post-upgrade, tags: post-upgrade }
  110. environment: "{{ proxy_env }}"
  111. - name: Upgrade calico and external cloud provider on all masters and nodes
  112. hosts: kube-master:kube-node
  113. gather_facts: False
  114. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  115. serial: "{{ serial | default('20%') }}"
  116. roles:
  117. - { role: kubespray-defaults }
  118. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  119. - { role: network_plugin, tags: network }
  120. - { role: kubernetes-apps/network_plugin, tags: network }
  121. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  122. - name: Finally handle worker upgrades, based on given batch size
  123. hosts: kube-node:!kube-master
  124. gather_facts: False
  125. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  126. serial: "{{ serial | default('20%') }}"
  127. roles:
  128. - { role: kubespray-defaults }
  129. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  130. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  131. - { role: kubernetes/node, tags: node }
  132. - { role: kubernetes/kubeadm, tags: kubeadm }
  133. - { role: kubernetes/node-label, tags: node-label }
  134. - { role: upgrade/post-upgrade, tags: post-upgrade }
  135. environment: "{{ proxy_env }}"
  136. - hosts: kube-master[0]
  137. gather_facts: False
  138. any_errors_fatal: true
  139. roles:
  140. - { role: kubespray-defaults }
  141. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  142. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }
  143. - hosts: calico-rr
  144. gather_facts: False
  145. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  146. roles:
  147. - { role: kubespray-defaults }
  148. - { role: network_plugin/calico/rr, tags: network }
  149. environment: "{{ proxy_env }}"
  150. - hosts: kube-master
  151. gather_facts: False
  152. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  153. roles:
  154. - { role: kubespray-defaults }
  155. - { role: kubernetes-apps, tags: apps }
  156. environment: "{{ proxy_env }}"
  157. - hosts: k8s-cluster
  158. gather_facts: False
  159. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  160. roles:
  161. - { role: kubespray-defaults }
  162. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }