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.

149 lines
5.6 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: bastion[0]
  16. gather_facts: False
  17. roles:
  18. - { role: kubespray-defaults}
  19. - { role: bastion-ssh-config, tags: ["localhost", "bastion"]}
  20. - hosts: k8s-cluster:etcd:calico-rr
  21. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  22. gather_facts: false
  23. vars:
  24. # Need to disable pipelining for bootstrap-os as some systems have requiretty in sudoers set, which makes pipelining
  25. # fail. bootstrap-os fixes this on these systems, so in later plays it can be enabled.
  26. ansible_ssh_pipelining: false
  27. roles:
  28. - { role: kubespray-defaults}
  29. - { role: bootstrap-os, tags: bootstrap-os}
  30. - name: Download images to ansible host cache via first kube-master node
  31. hosts: kube-master[0]
  32. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  33. roles:
  34. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost"}
  35. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  36. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  37. environment: "{{ proxy_env }}"
  38. - name: Prepare nodes for upgrade
  39. hosts: k8s-cluster:etcd:calico-rr
  40. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  41. roles:
  42. - { role: kubespray-defaults}
  43. - { role: kubernetes/preinstall, tags: preinstall }
  44. - { role: download, tags: download, when: "not skip_downloads" }
  45. environment: "{{ proxy_env }}"
  46. - name: Upgrade container engine on non-cluster nodes
  47. hosts: etcd:calico-rr:!k8s-cluster
  48. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  49. serial: "{{ serial | default('20%') }}"
  50. roles:
  51. - { role: kubespray-defaults}
  52. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  53. environment: "{{ proxy_env }}"
  54. - hosts: etcd
  55. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  56. roles:
  57. - { role: kubespray-defaults}
  58. - role: etcd
  59. tags: etcd
  60. vars:
  61. etcd_cluster_setup: true
  62. etcd_events_cluster_setup: false
  63. when: not etcd_kubeadm_enabled | default(false)
  64. - hosts: k8s-cluster
  65. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  66. roles:
  67. - { role: kubespray-defaults}
  68. - role: etcd
  69. tags: etcd
  70. vars:
  71. etcd_cluster_setup: false
  72. etcd_events_cluster_setup: false
  73. when: not etcd_kubeadm_enabled | default(false)
  74. - name: Handle upgrades to master components first to maintain backwards compat.
  75. hosts: kube-master
  76. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  77. serial: 1
  78. roles:
  79. - { role: kubespray-defaults}
  80. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  81. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  82. - { role: kubernetes/node, tags: node }
  83. - { role: kubernetes/master, tags: master, upgrade_cluster_setup: true }
  84. - { role: kubernetes/client, tags: client }
  85. - { role: kubernetes/node-label, tags: node-label }
  86. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  87. - { role: kubernetes-apps, tags: csi-driver }
  88. - { role: upgrade/post-upgrade, tags: post-upgrade }
  89. environment: "{{ proxy_env }}"
  90. - name: Upgrade calico and external cloud provider on all masters and nodes
  91. hosts: kube-master:kube-node
  92. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  93. serial: "{{ serial | default('20%') }}"
  94. roles:
  95. - { role: kubespray-defaults}
  96. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  97. - { role: network_plugin, tags: network }
  98. - { role: kubernetes-apps/network_plugin, tags: network }
  99. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  100. - name: Finally handle worker upgrades, based on given batch size
  101. hosts: kube-node:!kube-master
  102. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  103. serial: "{{ serial | default('20%') }}"
  104. roles:
  105. - { role: kubespray-defaults}
  106. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  107. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  108. - { role: kubernetes/node, tags: node }
  109. - { role: kubernetes/kubeadm, tags: kubeadm }
  110. - { role: kubernetes/node-label, tags: node-label }
  111. - { role: upgrade/post-upgrade, tags: post-upgrade }
  112. environment: "{{ proxy_env }}"
  113. - hosts: kube-master[0]
  114. any_errors_fatal: true
  115. roles:
  116. - { role: kubespray-defaults}
  117. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  118. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"]}
  119. - hosts: calico-rr
  120. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  121. roles:
  122. - { role: kubespray-defaults}
  123. - { role: network_plugin/calico/rr, tags: network }
  124. environment: "{{ proxy_env }}"
  125. - hosts: kube-master
  126. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  127. roles:
  128. - { role: kubespray-defaults}
  129. - { role: kubernetes-apps, tags: apps }
  130. environment: "{{ proxy_env }}"
  131. - hosts: k8s-cluster
  132. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  133. roles:
  134. - { role: kubespray-defaults}
  135. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }