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.

88 lines
3.3 KiB

  1. ---
  2. - name: Check ansible version
  3. import_playbook: ansible_version.yml
  4. - hosts: bastion[0]
  5. gather_facts: False
  6. roles:
  7. - { role: kubespray-defaults }
  8. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  9. - name: Bootstrap any new workers
  10. hosts: kube-node
  11. strategy: linear
  12. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  13. gather_facts: false
  14. roles:
  15. - { role: kubespray-defaults }
  16. - { role: bootstrap-os, tags: bootstrap-os }
  17. - name: Gather facts
  18. tags: always
  19. import_playbook: facts.yml
  20. - name: Generate the etcd certificates beforehand
  21. hosts: etcd
  22. gather_facts: False
  23. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  24. roles:
  25. - { role: kubespray-defaults }
  26. - { role: etcd, tags: etcd, etcd_cluster_setup: false }
  27. - name: Download images to ansible host cache via first kube-master node
  28. hosts: kube-master[0]
  29. gather_facts: False
  30. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  31. roles:
  32. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost" }
  33. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  34. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  35. - name: Target only workers to get kubelet installed and checking in on any new nodes(engine)
  36. hosts: kube-node
  37. gather_facts: False
  38. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  39. roles:
  40. - { role: kubespray-defaults }
  41. - { role: kubernetes/preinstall, tags: preinstall }
  42. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  43. - { role: download, tags: download, when: "not skip_downloads" }
  44. - { role: etcd, tags: etcd, etcd_cluster_setup: false, when: "not etcd_kubeadm_enabled|default(false)" }
  45. - name: Target only workers to get kubelet installed and checking in on any new nodes(node)
  46. hosts: kube-node
  47. gather_facts: False
  48. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  49. roles:
  50. - { role: kubespray-defaults }
  51. - { role: kubernetes/node, tags: node }
  52. - name: Upload control plane certs and retrieve encryption key
  53. hosts: kube-master | first
  54. tags: kubeadm
  55. tasks:
  56. - name: include needed vars
  57. include_vars: roles/kubespray-defaults/defaults/main.yaml
  58. - name: Upload control plane certificates
  59. command: >-
  60. {{ bin_dir }}/kubeadm init phase
  61. --config {{ kube_config_dir }}/kubeadm-config.yaml
  62. upload-certs
  63. --upload-certs
  64. environment: "{{ proxy_disable_env }}"
  65. register: kubeadm_upload_cert
  66. changed_when: false
  67. - name: set fact 'kubeadm_certificate_key' for later use
  68. set_fact:
  69. kubeadm_certificate_key: "{{ kubeadm_upload_cert.stdout_lines[-1] | trim }}"
  70. when: kubeadm_certificate_key is not defined
  71. - name: Target only workers to get kubelet installed and checking in on any new nodes(network)
  72. hosts: kube-node
  73. gather_facts: False
  74. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  75. roles:
  76. - { role: kubespray-defaults }
  77. - { role: kubernetes/kubeadm, tags: kubeadm }
  78. - { role: network_plugin, tags: network }
  79. - { role: kubernetes/node-label, tags: node-label }