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.

139 lines
5.0 KiB

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