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.

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