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.

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