-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy path12_setup_kubeadm_config.yml
35 lines (30 loc) · 1.38 KB
/
12_setup_kubeadm_config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
- name: Prepare kubeadm-config for cluster setup
hosts: masters[0]
become: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Set fact for k8s version
ansible.builtin.set_fact:
kubernetes_version: v{{ k8s.cluster_version }}.{{ '12' if k8s.cluster_version is version('1.29', '==') else '8' if k8s.cluster_version is version('1.30', '==') else '4' if k8s.cluster_version is version('1.31', '==') else '0' if k8s.cluster_version is version('1.32', '==') }}
- name: Process installation if cluster is not set
when: k8s_installed is not defined
block:
- name: Generate cluster token # noqa no-changed-when
ansible.builtin.command: kubeadm token generate
register: kubetoken_generated
- name: Set generated token as fact
ansible.builtin.set_fact:
kubetoken: "{{ kubetoken_generated.stdout }}"
- name: Generate certificate key # noqa no-changed-when
ansible.builtin.command: kubeadm certs certificate-key
register: kubecert_generated
- name: Set generated token as fact
ansible.builtin.set_fact:
kubecertkey: "{{ kubecert_generated.stdout }}"
- name: Add kubelet config for node
ansible.builtin.template:
src: templates/kubeadm-config.yaml.j2
dest: /tmp/kubeadm-config.yaml
mode: "0755"