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.

96 lines
3.5 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. 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: network_plugin, tags: network }
  87. - { role: kubernetes/node-label, tags: node-label }