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.

138 lines
4.9 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: Prepare nodes for upgrade
  31. hosts: k8s-cluster:etcd:calico-rr
  32. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  33. roles:
  34. - { role: kubespray-defaults}
  35. - { role: kubernetes/preinstall, tags: preinstall }
  36. - { role: download, tags: download, when: "not skip_downloads" }
  37. environment: "{{ proxy_env }}"
  38. - name: Upgrade container engine on non-cluster nodes
  39. hosts: etcd:calico-rr:!k8s-cluster
  40. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  41. serial: "{{ serial | default('20%') }}"
  42. roles:
  43. - { role: kubespray-defaults}
  44. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  45. environment: "{{ proxy_env }}"
  46. - hosts: etcd
  47. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  48. roles:
  49. - { role: kubespray-defaults}
  50. - role: etcd
  51. tags: etcd
  52. vars:
  53. etcd_cluster_setup: true
  54. etcd_events_cluster_setup: false
  55. when: not etcd_kubeadm_enabled | default(false)
  56. - hosts: k8s-cluster
  57. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  58. roles:
  59. - { role: kubespray-defaults}
  60. - role: etcd
  61. tags: etcd
  62. vars:
  63. etcd_cluster_setup: false
  64. etcd_events_cluster_setup: false
  65. when: not etcd_kubeadm_enabled | default(false)
  66. - name: Handle upgrades to master components first to maintain backwards compat.
  67. hosts: kube-master
  68. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  69. serial: 1
  70. roles:
  71. - { role: kubespray-defaults}
  72. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  73. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  74. - { role: kubernetes/node, tags: node }
  75. - { role: kubernetes/master, tags: master, upgrade_cluster_setup: true }
  76. - { role: kubernetes/client, tags: client }
  77. - { role: kubernetes/node-label, tags: node-label }
  78. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  79. - { role: upgrade/post-upgrade, tags: post-upgrade }
  80. environment: "{{ proxy_env }}"
  81. - name: Upgrade calico on all masters and nodes
  82. hosts: kube-master:kube-node
  83. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  84. serial: "{{ serial | default('20%') }}"
  85. roles:
  86. - { role: kubespray-defaults}
  87. - { role: network_plugin, tags: network }
  88. - { role: kubernetes-apps/network_plugin, tags: network }
  89. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  90. - name: Finally handle worker upgrades, based on given batch size
  91. hosts: kube-node:!kube-master
  92. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  93. serial: "{{ serial | default('20%') }}"
  94. roles:
  95. - { role: kubespray-defaults}
  96. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  97. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  98. - { role: kubernetes/node, tags: node }
  99. - { role: kubernetes/kubeadm, tags: kubeadm }
  100. - { role: kubernetes/node-label, tags: node-label }
  101. - { role: upgrade/post-upgrade, tags: post-upgrade }
  102. environment: "{{ proxy_env }}"
  103. - hosts: kube-master[0]
  104. any_errors_fatal: true
  105. roles:
  106. - { role: kubespray-defaults}
  107. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  108. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"]}
  109. - hosts: calico-rr
  110. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  111. roles:
  112. - { role: kubespray-defaults}
  113. - { role: network_plugin/calico/rr, tags: network }
  114. environment: "{{ proxy_env }}"
  115. - hosts: kube-master
  116. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  117. roles:
  118. - { role: kubespray-defaults}
  119. - { role: kubernetes-apps, tags: apps }
  120. environment: "{{ proxy_env }}"
  121. - hosts: k8s-cluster
  122. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  123. roles:
  124. - { role: kubespray-defaults}
  125. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }