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.

108 lines
4.0 KiB

  1. ---
  2. - name: Check ansible version
  3. import_playbook: ansible_version.yml
  4. - name: Ensure compatibility with old groups
  5. import_playbook: legacy_groups.yml
  6. - hosts: bastion[0]
  7. gather_facts: False
  8. environment: "{{ proxy_disable_env }}"
  9. roles:
  10. - { role: kubespray-defaults }
  11. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  12. - name: Bootstrap any new workers
  13. hosts: kube_node
  14. strategy: linear
  15. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  16. gather_facts: false
  17. environment: "{{ proxy_disable_env }}"
  18. roles:
  19. - { role: kubespray-defaults }
  20. - { role: bootstrap-os, tags: bootstrap-os }
  21. - name: Gather facts
  22. tags: always
  23. import_playbook: facts.yml
  24. - name: Generate the etcd certificates beforehand
  25. hosts: etcd
  26. gather_facts: False
  27. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  28. environment: "{{ proxy_disable_env }}"
  29. roles:
  30. - { role: kubespray-defaults }
  31. - { role: etcd, tags: etcd, etcd_cluster_setup: false }
  32. - name: Download images to ansible host cache via first kube_control_plane node
  33. hosts: kube_control_plane[0]
  34. gather_facts: False
  35. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  36. environment: "{{ proxy_disable_env }}"
  37. roles:
  38. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost" }
  39. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  40. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  41. - name: Target only workers to get kubelet installed and checking in on any new nodes(engine)
  42. hosts: kube_node
  43. gather_facts: False
  44. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  45. environment: "{{ proxy_disable_env }}"
  46. roles:
  47. - { role: kubespray-defaults }
  48. - { role: kubernetes/preinstall, tags: preinstall }
  49. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  50. - { role: download, tags: download, when: "not skip_downloads" }
  51. - { role: etcd, tags: etcd, etcd_cluster_setup: false, when: "not etcd_kubeadm_enabled|default(false)" }
  52. - name: Target only workers to get kubelet installed and checking in on any new nodes(node)
  53. hosts: kube_node
  54. gather_facts: False
  55. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  56. environment: "{{ proxy_disable_env }}"
  57. roles:
  58. - { role: kubespray-defaults }
  59. - { role: kubernetes/node, tags: node }
  60. - name: Upload control plane certs and retrieve encryption key
  61. hosts: kube_control_plane | first
  62. environment: "{{ proxy_disable_env }}"
  63. gather_facts: False
  64. tags: kubeadm
  65. roles:
  66. - { role: kubespray-defaults }
  67. tasks:
  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: kubernetes/node-label, tags: node-label }
  90. - { role: network_plugin, tags: network }
  91. - hosts: k8s_cluster
  92. gather_facts: False
  93. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  94. environment: "{{ proxy_disable_env }}"
  95. roles:
  96. - { role: kubespray-defaults }
  97. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }