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.

97 lines
3.6 KiB

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