-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrhel_common.yaml
79 lines (69 loc) · 2.34 KB
/
rhel_common.yaml
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
- name: Setup Kubernetes With Common Configurations
hosts: all
become: true
vars:
kubernetes_version: "v1.29"
project_path: "prerelease:/main"
packages:
- iproute-tc
- git
tasks:
- name: Disable swap
shell: swapoff -a
- name: Add swapoff to crontab for reboot
cron:
name: "Ensure swapoff -a runs at reboot"
job: "/sbin/swapoff -a"
special_time: "reboot"
state: present
- name: Install required packages
dnf:
name: "{{ packages }}"
state: present
when: True
- name: Load kernel modules
modprobe:
name: "{{ item }}"
loop:
- overlay
- br_netfilter
- name: Configure kernel modules
copy:
content: "{{ item.content }}"
dest: "{{ item.dest }}"
loop:
- { content: "overlay\nbr_netfilter", dest: "/etc/modules-load.d/k8s.conf" }
- { content: "net.bridge.bridge-nf-call-iptables = 1\nnet.ipv4.ip_forward = 1\nnet.bridge.bridge-nf-call-ip6tables = 1", dest: "/etc/sysctl.d/k8s.conf" }
- name: Apply sysctl settings
command: sysctl --system
- name: Disable SELinux
shell: setenforce 0 && sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
- name: Add Kubernetes repository
copy:
content: "{{ item.content }}"
dest: "/etc/yum.repos.d/{{ item.repo_name }}"
loop:
- { content: "[kubernetes]\nname=Kubernetes\nbaseurl=https://pkgs.k8s.io/core:/stable:/{{ kubernetes_version }}/rpm/\nenabled=1\ngpgcheck=1\ngpgkey=https://pkgs.k8s.io/core:/stable:/{{ kubernetes_version }}/rpm/repodata/repomd.xml.key", repo_name: "kubernetes.repo" }
- copy:
src: cri-o-1.29.9~dev-150500.2.1.x86_64.rpm
dest: cri-o-1.29.9~dev-150500.2.1.x86_64.rpm
- command: yum install cri-o-1.29.9~dev-150500.2.1.x86_64.rpm -y
- name: Install Kubernetes packages
dnf:
name: "{{ item }}"
state: present
loop:
- kubelet
- kubeadm
- kubectl
- cri-tools
- name: Enable and start CRI-O
service:
name: crio
state: started
enabled: true
- name: Enable and start kubelet
service:
name: kubelet
state: started
enabled: true