-
Notifications
You must be signed in to change notification settings - Fork 76
/
11_install_kube_packages.yml
107 lines (94 loc) · 2.94 KB
/
11_install_kube_packages.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
- name: Ensure kube packages are installed
hosts: k8s_nodes
become: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Add Kubernetes repository
ansible.builtin.yum_repository:
name: kubernetes
description: Kubernetes repo
baseurl: "{{ kubernetes.centos.k8s_repo }}"
gpgcheck: true
repo_gpgcheck: true
gpgkey: "{{ kubernetes.centos.k8s_repo_key }}"
exclude: kubelet kubeadm kubectl
when: k8s.cluster_os == 'CentOS'
- name: Ensure required packages for kubetools are installed
ansible.builtin.apt:
name:
- apt-transport-https
- curl
state: present
when: k8s.cluster_os == 'Ubuntu'
- name: Add kube-repo key
ansible.builtin.apt_key:
url: "{{ kubernetes.ubuntu.k8s_repo_key }}"
keyring: "{{ kubernetes.ubuntu.k8s_repo_keyring }}"
state: present
when: k8s.cluster_os == 'Ubuntu'
- name: Ensure the presence of apt-repo for kubernetes packages
ansible.builtin.apt_repository:
repo: "{{ kubernetes.ubuntu.k8s_repo }}"
filename: "{{ kubernetes.ubuntu.k8s_repo_file }}"
state: present
when: k8s.cluster_os == 'Ubuntu'
- name: Ensure Kubernetes packages are installed
ansible.builtin.apt:
name: "{{ kubernetes.packages.k8s_packages }}"
state: present
when: k8s.cluster_os == 'Ubuntu'
- name: Ensure kubelet, kubeadm, kubectl are on hold
ansible.builtin.dpkg_selections:
name: "{{ item }}"
selection: hold
loop:
- kubectl
- kubeadm
- kubelet
when: k8s.cluster_os == 'Ubuntu'
- name: Disable swap # noqa no-changed-when
ansible.builtin.command: swapoff -a
- name: Remove swap entry from fstab
ansible.builtin.lineinfile:
line: "/dev/mapper/cl-swap swap"
path: /etc/fstab
state: absent
- name: Disable SELinux
ansible.posix.selinux:
state: disabled
register: selinux_output
notify: Reboot host
when: k8s.cluster_os == 'CentOS'
- name: Install kubepackages
ansible.builtin.yum:
name: "{{ kubernetes.packages.k8s_packages }}"
state: present
disable_excludes: kubernetes
when: k8s.cluster_os == 'CentOS'
- name: Install lvm2 for rook support and git for installing rook
ansible.builtin.yum:
name:
- lvm2
- git
when:
- rook_ceph.install_rook
- k8s.cluster_os == 'CentOS'
- name: Install lvm2 for rook support and git for installing rook
ansible.builtin.apt:
name:
- lvm2
- git
when:
- rook_ceph.install_rook
- k8s.cluster_os == 'Ubuntu'
- name: Enable kubelet
ansible.builtin.systemd:
name: kubelet
state: started
enabled: true
notify: Reboot host
handlers:
- name: Reboot host
ansible.builtin.reboot: