-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-dependencies.yml
154 lines (129 loc) · 4.04 KB
/
1-dependencies.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
#Shamelessly copied from https://spacelift.io/blog/ansible-kubernetes
#I did not find the code posted on github and needed it for my training
#I made a few minor modifications...
- name: Kubernetes Dependencies
hosts: all
become: true
tasks:
- name: Updates
apt:
name: "*"
state: latest
update_cache: true
# reboots are an issue
# - name: Reboot
# shell: reboot
- name: Pause for 5 minutes to build app cache
ansible.builtin.pause:
minutes: 5
- name: Disable SWAP
shell: |
swapoff -a
- name: Disable SWAP in fstab
replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
replace: '# \1'
- name: Create an empty file for the containerd module
copy:
content: ""
dest: /etc/modules-load.d/containerd.conf
force: no
- name: Configure modules for containerd
blockinfile:
path: /etc/modules-load.d/containerd.conf
block: |
overlay
br_netfilter
- name: Create an empty file for K8S sysctl parameters
copy:
content: ""
dest: /etc/sysctl.d/99-kubernetes-cri.conf
force: no
- name: Configure sysctl parameters for K8S
lineinfile:
path: /etc/sysctl.d/99-kubernetes-cri.conf
line: "{{ item }}"
with_items:
- "net.bridge.bridge-nf-call-iptables = 1"
- "net.ipv4.ip_forward = 1"
- "net.bridge.bridge-nf-call-ip6tables = 1"
- name: Apply sysctl parameters
command: sysctl --system
- name: Install APT Transport HTTPS
apt:
name: apt-transport-https
state: present
- name: Add Docker apt-key
get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker-apt-keyring.asc
mode: "0644"
force: true
- name: Add Docker's APT repo
apt_repository:
repo: "deb [arch={{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }} signed-by=/etc/apt/keyrings/docker-apt-keyring.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
- name: Add Kubernetes apt-key
get_url:
url: https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key
dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc
mode: "0644"
force: true
- name: Add Kubernetes APT repository
apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.asc] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /"
state: present
update_cache: yes
- name: Install containerd
apt:
name: containerd.io
state: present
- name: Create containerd directory
file:
path: /etc/containerd
state: directory
- name: Add containerd configuration
shell: /usr/bin/containerd config default > /etc/containerd/config.toml
- name: Configuring Systemd cgroup driver for containerd
lineinfile:
path: /etc/containerd/config.toml
regexp: " SystemdCgroup = false"
line: " SystemdCgroup = true"
- name: Enable the containerd service and start service
systemd:
name: containerd
state: restarted
enabled: yes
daemon-reload: yes
- name: Install Kubelet
apt:
name: kubelet
state: present
update_cache: true
- name: Install Kubeadm
apt:
name: kubeadm
state: present
- name: Enable the Kubelet service
service:
name: kubelet
enabled: yes
- name: Load br_netfilter kernel module
community.general.modprobe:
name: br_netfilter
state: present
- name: Set bridge-nf-call-iptables
sysctl:
name: net.bridge.bridge-nf-call-iptables
value: 1
- name: Set ip_forward
sysctl:
name: net.ipv4.ip_forward
value: 1
# reboots are an issue
# - name: Reboot
# shell: reboot
...