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.

114 lines
4.1 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
  32. tags: etcd
  33. vars:
  34. etcd_cluster_setup: false
  35. etcd_events_cluster_setup: false
  36. when: etcd_deployment_type != "kubeadm"
  37. - name: Download images to ansible host cache via first kube_control_plane node
  38. hosts: kube_control_plane[0]
  39. gather_facts: False
  40. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  41. environment: "{{ proxy_disable_env }}"
  42. roles:
  43. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost" }
  44. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  45. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  46. - name: Target only workers to get kubelet installed and checking in on any new nodes(engine)
  47. hosts: kube_node
  48. gather_facts: False
  49. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  50. environment: "{{ proxy_disable_env }}"
  51. roles:
  52. - { role: kubespray-defaults }
  53. - { role: kubernetes/preinstall, tags: preinstall }
  54. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  55. - { role: download, tags: download, when: "not skip_downloads" }
  56. - { role: etcd, tags: etcd, etcd_cluster_setup: false, when: "etcd_deployment_type != 'kubeadm'" }
  57. - name: Target only workers to get kubelet installed and checking in on any new nodes(node)
  58. hosts: kube_node
  59. gather_facts: False
  60. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  61. environment: "{{ proxy_disable_env }}"
  62. roles:
  63. - { role: kubespray-defaults }
  64. - { role: kubernetes/node, tags: node }
  65. - name: Upload control plane certs and retrieve encryption key
  66. hosts: kube_control_plane | first
  67. environment: "{{ proxy_disable_env }}"
  68. gather_facts: False
  69. tags: kubeadm
  70. roles:
  71. - { role: kubespray-defaults }
  72. tasks:
  73. - name: Upload control plane certificates
  74. command: >-
  75. {{ bin_dir }}/kubeadm init phase
  76. --config {{ kube_config_dir }}/kubeadm-config.yaml
  77. upload-certs
  78. --upload-certs
  79. environment: "{{ proxy_disable_env }}"
  80. register: kubeadm_upload_cert
  81. changed_when: false
  82. - name: set fact 'kubeadm_certificate_key' for later use
  83. set_fact:
  84. kubeadm_certificate_key: "{{ kubeadm_upload_cert.stdout_lines[-1] | trim }}"
  85. when: kubeadm_certificate_key is not defined
  86. - name: Target only workers to get kubelet installed and checking in on any new nodes(network)
  87. hosts: kube_node
  88. gather_facts: False
  89. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  90. environment: "{{ proxy_disable_env }}"
  91. roles:
  92. - { role: kubespray-defaults }
  93. - { role: kubernetes/kubeadm, tags: kubeadm }
  94. - { role: kubernetes/node-label, tags: node-label }
  95. - { role: network_plugin, tags: network }
  96. - name: Apply resolv.conf changes now that cluster DNS is up
  97. hosts: k8s_cluster
  98. gather_facts: False
  99. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  100. environment: "{{ proxy_disable_env }}"
  101. roles:
  102. - { role: kubespray-defaults }
  103. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf, dns_late: true }