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.

99 lines
3.7 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. roles:
  64. - { role: kubespray-defaults }
  65. tasks:
  66. - name: include needed vars
  67. include_vars: roles/kubespray-defaults/defaults/main.yaml
  68. - name: Upload control plane certificates
  69. command: >-
  70. {{ bin_dir }}/kubeadm init phase
  71. --config {{ kube_config_dir }}/kubeadm-config.yaml
  72. upload-certs
  73. --upload-certs
  74. environment: "{{ proxy_disable_env }}"
  75. register: kubeadm_upload_cert
  76. changed_when: false
  77. - name: set fact 'kubeadm_certificate_key' for later use
  78. set_fact:
  79. kubeadm_certificate_key: "{{ kubeadm_upload_cert.stdout_lines[-1] | trim }}"
  80. when: kubeadm_certificate_key is not defined
  81. - name: Target only workers to get kubelet installed and checking in on any new nodes(network)
  82. hosts: kube-node
  83. gather_facts: False
  84. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  85. environment: "{{ proxy_disable_env }}"
  86. roles:
  87. - { role: kubespray-defaults }
  88. - { role: kubernetes/kubeadm, tags: kubeadm }
  89. - { role: network_plugin, tags: network }
  90. - { role: kubernetes/node-label, tags: node-label }