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.

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