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.

127 lines
4.5 KiB

6 years ago
  1. ---
  2. - hosts: localhost
  3. gather_facts: false
  4. tasks:
  5. - name: "Check ansible version !=2.7.0"
  6. assert:
  7. msg: "Ansible V2.7.0 can't be used until: https://github.com/ansible/ansible/issues/46600 is fixed"
  8. that:
  9. - ansible_version.string is version("2.7.0", "!=")
  10. - ansible_version.string is version("2.5.0", ">=")
  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. #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. #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. #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. - hosts: k8s-cluster
  105. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  106. roles:
  107. - { role: kubespray-defaults}
  108. - { role: dnsmasq, when: "dns_mode == 'dnsmasq_kubedns'", tags: dnsmasq }
  109. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }
  110. - hosts: kube-master
  111. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  112. roles:
  113. - { role: kubespray-defaults}
  114. - { role: kubernetes-apps, tags: apps }