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.

122 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.0"
  7. assert:
  8. msg: "Ansible V2.7.0 can't be used until: https://github.com/ansible/ansible/issues/46600 is fixed"
  9. that:
  10. - ansible_version.string is version("2.7.0", "!=")
  11. - ansible_version.string is version("2.6.0", ">=")
  12. tags:
  13. - check
  14. vars:
  15. ansible_connection: local
  16. - hosts: bastion[0]
  17. gather_facts: False
  18. roles:
  19. - { role: kubespray-defaults}
  20. - { role: bastion-ssh-config, tags: ["localhost", "bastion"]}
  21. - hosts: k8s-cluster:etcd:calico-rr
  22. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  23. gather_facts: false
  24. vars:
  25. # Need to disable pipelining for bootstrap-os as some systems have requiretty in sudoers set, which makes pipelining
  26. # fail. bootstrap-os fixes this on these systems, so in later plays it can be enabled.
  27. ansible_ssh_pipelining: false
  28. roles:
  29. - { role: kubespray-defaults}
  30. - { role: bootstrap-os, tags: bootstrap-os}
  31. - hosts: k8s-cluster:etcd:calico-rr
  32. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  33. vars:
  34. ansible_ssh_pipelining: true
  35. gather_facts: true
  36. pre_tasks:
  37. - name: gather facts from all instances
  38. setup:
  39. delegate_to: "{{item}}"
  40. delegate_facts: True
  41. with_items: "{{ groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]) }}"
  42. - hosts: k8s-cluster:etcd:calico-rr
  43. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  44. serial: "{{ serial | default('20%') }}"
  45. roles:
  46. - { role: kubespray-defaults}
  47. - { role: kubernetes/preinstall, tags: preinstall }
  48. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  49. - { role: download, tags: download, when: "not skip_downloads" }
  50. environment: "{{proxy_env}}"
  51. - hosts: etcd
  52. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  53. roles:
  54. - { role: kubespray-defaults}
  55. - { role: etcd, tags: etcd, etcd_cluster_setup: true }
  56. - hosts: k8s-cluster
  57. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  58. roles:
  59. - { role: kubespray-defaults}
  60. - { role: etcd, tags: etcd, etcd_cluster_setup: false }
  61. - name: Handle upgrades to master components first to maintain backwards compat.
  62. hosts: kube-master
  63. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  64. serial: 1
  65. roles:
  66. - { role: kubespray-defaults}
  67. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  68. - { role: kubernetes/node, tags: node }
  69. - { role: kubernetes/master, tags: master, upgrade_cluster_setup: true }
  70. - { role: kubernetes/client, tags: client }
  71. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  72. - { role: upgrade/post-upgrade, tags: post-upgrade }
  73. environment: "{{proxy_env}}"
  74. - name: Upgrade calico on all masters and nodes
  75. hosts: kube-master:kube-node
  76. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  77. serial: "{{ serial | default('20%') }}"
  78. roles:
  79. - { role: kubespray-defaults}
  80. - { role: network_plugin, tags: network }
  81. - { role: kubernetes-apps/network_plugin, tags: network }
  82. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  83. - name: Finally handle worker upgrades, based on given batch size
  84. hosts: kube-node:!kube-master
  85. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  86. serial: "{{ serial | default('20%') }}"
  87. roles:
  88. - { role: kubespray-defaults}
  89. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  90. - { role: kubernetes/node, tags: node }
  91. - { role: kubernetes/kubeadm, tags: kubeadm }
  92. - { role: upgrade/post-upgrade, tags: post-upgrade }
  93. environment: "{{proxy_env}}"
  94. - hosts: kube-master[0]
  95. any_errors_fatal: true
  96. roles:
  97. - { role: kubespray-defaults}
  98. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  99. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"]}
  100. - hosts: calico-rr
  101. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  102. roles:
  103. - { role: kubespray-defaults}
  104. - { role: network_plugin/calico/rr, tags: network }
  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. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }