-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.yml
More file actions
94 lines (77 loc) · 2.71 KB
/
Copy pathkernel.yml
File metadata and controls
94 lines (77 loc) · 2.71 KB
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
- name: Install development tools
package:
name: "{{ item }}"
state: installed
loop: "{{ build_packages }}"
- name: Calculate kernel branch name for Amazon Linux 2
set_fact:
branch_name: "amazon-{{ ansible_kernel | regex_replace('^(?P<ver>\\d+.\\d+.)(?P<build>.*)', '\\g<ver>y/master') }}"
when: ansible_facts["distribution_major_version"] == "2"
- name: Calculate kernel branch name for Amazon Linux 2023
set_fact:
branch_name: "amazon-{{ ansible_kernel | regex_replace('^(?P<ver>\\d+.\\d+.)(?P<build>.*)', '\\g<ver>y/mainline') }}"
when: ansible_facts["distribution_major_version"] == "2023"
- name: Clone source code for the current kernel
git:
repo: "https://github.com/amazonlinux/linux.git"
version: "{{ branch_name }}"
dest: "{{ build_dir }}"
depth: 1
- name: Copy current config to the build dir
copy:
src: "/boot/config-{{ ansible_kernel }}"
dest: "{{ build_dir }}/.config"
- name: Enable full tickless mode
lineinfile:
path: "{{ build_dir }}/.config"
regexp: "^#\ CONFIG_NO_HZ_FULL.*$"
line: "CONFIG_NO_HZ_FULL=y"
- name: Disable idle tickless mode
lineinfile:
path: "{{ build_dir }}/.config"
regexp: "^CONFIG_NO_HZ_IDLE"
line: "# CONFIG_NO_HZ_IDLE is not set"
- name: Verify and fix the new config
shell:
cmd: "yes \"\" | make oldconfig"
chdir: "{{ build_dir }}"
- name: Build a new kernel
shell:
cmd: "make -j {{ ansible_processor_vcpus }}"
chdir: "{{ build_dir }}"
- name: Install modules
shell:
cmd: "make modules_install"
chdir: "{{ build_dir }}"
- name: Get full version of the new kernel
shell:
cmd: "make kernelversion"
chdir: "{{ build_dir }}"
register: kernel_version
- name: Install kernel config
copy:
src: "{{ build_dir }}/.config"
dest: "/boot/config-{{ kernel_version.stdout }}-{{ kernel_prefix }}"
- name: Install built kernel
copy:
src: "{{ build_dir }}/arch/{{ ansible_machine }}/boot/bzImage"
dest: "/boot/vmlinuz-{{ kernel_version.stdout }}-{{ kernel_prefix }}"
- name: Generate initramfs
shell:
cmd: "dracut --hostonly --kver {{ kernel_version.stdout }}"
chdir: "{{ build_dir }}"
- name: Add built kernel to GRUB
shell:
cmd: "grubby --grub2 --add-kernel=/boot/vmlinuz-{{ kernel_version.stdout }}-{{ kernel_prefix }} --title=\"Amazon Linux Tickless\" --initrd=/boot/initramfs-{{ kernel_version.stdout }}.img --copy-default"
- name: Set build kernel as default
shell:
cmd: "grubby --set-default=/boot/vmlinuz-{{ kernel_version.stdout }}-{{ kernel_prefix }}"
- name: Remove development tools
package:
name: "{{ item }}"
state: absent
loop: "{{ build_packages }}"
- name: Remove kernel source
file:
path: "{{ build_dir }}"
state: absent