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.

124 lines
4.6 KiB

  1. ---
  2. - name: Check ansible version
  3. import_playbook: ansible_version.yml
  4. - name: Ensure compatibility with old groups
  5. import_playbook: legacy_groups.yml
  6. - hosts: bastion[0]
  7. gather_facts: False
  8. environment: "{{ proxy_disable_env }}"
  9. roles:
  10. - { role: kubespray-defaults }
  11. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  12. - name: Bootstrap any new workers
  13. hosts: kube_node
  14. strategy: linear
  15. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  16. gather_facts: false
  17. environment: "{{ proxy_disable_env }}"
  18. roles:
  19. - { role: kubespray-defaults }
  20. - { role: bootstrap-os, tags: bootstrap-os }
  21. - name: Gather facts
  22. tags: always
  23. import_playbook: facts.yml
  24. - name: Generate the etcd certificates beforehand
  25. hosts: etcd:kube_control_plane
  26. gather_facts: False
  27. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  28. environment: "{{ proxy_disable_env }}"
  29. roles:
  30. - { role: kubespray-defaults }
  31. - role: etcd
  32. tags: etcd
  33. vars:
  34. etcd_cluster_setup: false
  35. etcd_events_cluster_setup: false
  36. when:
  37. - etcd_deployment_type != "kubeadm"
  38. - kube_network_plugin in ["calico", "flannel", "canal", "cilium"] or cilium_deploy_additionally | default(false) | bool
  39. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  40. - name: Download images to ansible host cache via first kube_control_plane node
  41. hosts: kube_control_plane[0]
  42. gather_facts: False
  43. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  44. environment: "{{ proxy_disable_env }}"
  45. roles:
  46. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost" }
  47. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  48. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  49. - name: Target only workers to get kubelet installed and checking in on any new nodes(engine)
  50. hosts: kube_node
  51. gather_facts: False
  52. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  53. environment: "{{ proxy_disable_env }}"
  54. roles:
  55. - { role: kubespray-defaults }
  56. - { role: kubernetes/preinstall, tags: preinstall }
  57. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  58. - { role: download, tags: download, when: "not skip_downloads" }
  59. - role: etcd
  60. tags: etcd
  61. vars:
  62. etcd_cluster_setup: false
  63. when:
  64. - etcd_deployment_type != "kubeadm"
  65. - kube_network_plugin in ["calico", "flannel", "canal", "cilium"] or cilium_deploy_additionally | default(false) | bool
  66. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  67. - name: Target only workers to get kubelet installed and checking in on any new nodes(node)
  68. hosts: kube_node
  69. gather_facts: False
  70. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  71. environment: "{{ proxy_disable_env }}"
  72. roles:
  73. - { role: kubespray-defaults }
  74. - { role: kubernetes/node, tags: node }
  75. - name: Upload control plane certs and retrieve encryption key
  76. hosts: kube_control_plane | first
  77. environment: "{{ proxy_disable_env }}"
  78. gather_facts: False
  79. tags: kubeadm
  80. roles:
  81. - { role: kubespray-defaults }
  82. tasks:
  83. - name: Upload control plane certificates
  84. command: >-
  85. {{ bin_dir }}/kubeadm init phase
  86. --config {{ kube_config_dir }}/kubeadm-config.yaml
  87. upload-certs
  88. --upload-certs
  89. environment: "{{ proxy_disable_env }}"
  90. register: kubeadm_upload_cert
  91. changed_when: false
  92. - name: set fact 'kubeadm_certificate_key' for later use
  93. set_fact:
  94. kubeadm_certificate_key: "{{ kubeadm_upload_cert.stdout_lines[-1] | trim }}"
  95. when: kubeadm_certificate_key is not defined
  96. - name: Target only workers to get kubelet installed and checking in on any new nodes(network)
  97. hosts: kube_node
  98. gather_facts: False
  99. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  100. environment: "{{ proxy_disable_env }}"
  101. roles:
  102. - { role: kubespray-defaults }
  103. - { role: kubernetes/kubeadm, tags: kubeadm }
  104. - { role: kubernetes/node-label, tags: node-label }
  105. - { role: network_plugin, tags: network }
  106. - name: Apply resolv.conf changes now that cluster DNS is up
  107. hosts: k8s_cluster
  108. gather_facts: False
  109. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  110. environment: "{{ proxy_disable_env }}"
  111. roles:
  112. - { role: kubespray-defaults }
  113. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf, dns_late: true }