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.

163 lines
6.1 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: Download images to ansible host cache via first kube-master node
  44. hosts: kube-master[0]
  45. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  46. roles:
  47. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost"}
  48. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  49. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  50. environment: "{{ proxy_env }}"
  51. - name: Prepare nodes for upgrade
  52. hosts: k8s-cluster:etcd:calico-rr
  53. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  54. roles:
  55. - { role: kubespray-defaults }
  56. - { role: kubernetes/preinstall, tags: preinstall }
  57. - { role: download, tags: download, when: "not skip_downloads" }
  58. environment: "{{ proxy_env }}"
  59. - name: Upgrade container engine on non-cluster nodes
  60. hosts: etcd:calico-rr:!k8s-cluster
  61. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  62. serial: "{{ serial | default('20%') }}"
  63. roles:
  64. - { role: kubespray-defaults }
  65. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  66. environment: "{{ proxy_env }}"
  67. - hosts: etcd
  68. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  69. roles:
  70. - { role: kubespray-defaults }
  71. - role: etcd
  72. tags: etcd
  73. vars:
  74. etcd_cluster_setup: true
  75. etcd_events_cluster_setup: false
  76. when: not etcd_kubeadm_enabled | default(false)
  77. - hosts: k8s-cluster
  78. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  79. roles:
  80. - { role: kubespray-defaults }
  81. - role: etcd
  82. tags: etcd
  83. vars:
  84. etcd_cluster_setup: false
  85. etcd_events_cluster_setup: false
  86. when: not etcd_kubeadm_enabled | default(false)
  87. - name: Handle upgrades to master components first to maintain backwards compat.
  88. hosts: kube-master
  89. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  90. serial: 1
  91. roles:
  92. - { role: kubespray-defaults }
  93. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  94. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  95. - { role: kubernetes/node, tags: node }
  96. - { role: kubernetes/master, tags: master, upgrade_cluster_setup: true }
  97. - { role: kubernetes/client, tags: client }
  98. - { role: kubernetes/node-label, tags: node-label }
  99. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  100. - { role: kubernetes-apps, tags: csi-driver }
  101. - { role: upgrade/post-upgrade, tags: post-upgrade }
  102. environment: "{{ proxy_env }}"
  103. - name: Upgrade calico and external cloud provider on all masters and nodes
  104. hosts: kube-master:kube-node
  105. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  106. serial: "{{ serial | default('20%') }}"
  107. roles:
  108. - { role: kubespray-defaults }
  109. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  110. - { role: network_plugin, tags: network }
  111. - { role: kubernetes-apps/network_plugin, tags: network }
  112. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  113. - name: Finally handle worker upgrades, based on given batch size
  114. hosts: kube-node:!kube-master
  115. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  116. serial: "{{ serial | default('20%') }}"
  117. roles:
  118. - { role: kubespray-defaults }
  119. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  120. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  121. - { role: kubernetes/node, tags: node }
  122. - { role: kubernetes/kubeadm, tags: kubeadm }
  123. - { role: kubernetes/node-label, tags: node-label }
  124. - { role: upgrade/post-upgrade, tags: post-upgrade }
  125. environment: "{{ proxy_env }}"
  126. - hosts: kube-master[0]
  127. any_errors_fatal: true
  128. roles:
  129. - { role: kubespray-defaults }
  130. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  131. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }
  132. - hosts: calico-rr
  133. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  134. roles:
  135. - { role: kubespray-defaults }
  136. - { role: network_plugin/calico/rr, tags: network }
  137. environment: "{{ proxy_env }}"
  138. - hosts: kube-master
  139. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  140. roles:
  141. - { role: kubespray-defaults }
  142. - { role: kubernetes-apps, tags: apps }
  143. environment: "{{ proxy_env }}"
  144. - hosts: k8s-cluster
  145. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  146. roles:
  147. - { role: kubespray-defaults }
  148. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }