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.

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