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.

104 lines
4.1 KiB

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