Skip to content

Commit 8a304f8

Browse files
chuckleverKPD
authored andcommitted
Experimental: Add a separate install_linux role
Add a role that can grab the artifacts in workflows/linux/artifacts and install them on all guests/instances. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 79803bb commit 8a304f8

File tree

13 files changed

+750
-0
lines changed

13 files changed

+750
-0
lines changed

playbooks/install_linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- hosts: all
3+
roles:
4+
- role: install_linux
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
bootlinux
2+
=========
3+
4+
The ansible bootlinux lets you get, build and install Linux. It also lets you
5+
apply custom patches, remove kernels, etc. Anything you have to do with regards
6+
to generic kernel development. The defaults it will track one of the latest
7+
stable kernels that are still supported, using the linux stable git tree.
8+
9+
Requirements
10+
------------
11+
12+
You are expected to have an extra partition
13+
14+
Role Variables
15+
--------------
16+
17+
* infer_uid_and_group: defaults to False, if set to True, then we will ignore
18+
the passed on data_user and data_group and instead try to infer this by
19+
inspecting the `whoami` and getent on the logged in target system we are
20+
provisioning. So if user sam is running able on a host, targetting a system
21+
called foofighter and logging into that system using username pincho,
22+
then the data_user will be set overwritten and set to pincho. We will then
23+
also lookup for pincho's default group id and use that for data_group.
24+
This is useful if you are targetting a slew of systems and don't really
25+
want to deal with the complexities of the username and group, and the
26+
default target username you use to ssh into a system suffices to use as
27+
a base. This is set to False to remain compatible with old users of
28+
this role.
29+
* data_path: where to place the git trees we clone under
30+
* data_user: the user to assign permissions to
31+
* data_group: the group to assign permissions to
32+
33+
* data_device: the target device to use for the data partition
34+
* data_fstype: the filesystem to store the data parition under
35+
* data_label: the label to use
36+
* data_fs_opts: the filesystem options to use, you want to ensure to add the
37+
label
38+
39+
* target_linux_admin_name: your developer name
40+
* target_linux_admin_email: your email
41+
* target_linux_git: the git tree to clone, by default this is the linux-stable
42+
tree
43+
* target_linux_tree: the name of the tree
44+
* target_linux_dir_path: where to place the tree on the target system
45+
46+
* target_linux_ref : the actual tag as used on linux, so v4.19.62
47+
* target_linux_extra_patch: if defined an extra patch to apply with git
48+
am prior to compilation
49+
* target_linux_config: the configuration file to use
50+
* make: the make command to use
51+
* target_linux_make_cmd: the actual full make command and its arguments
52+
* target_linux_make_install_cmd: the install command
53+
54+
Dependencies
55+
------------
56+
57+
None.
58+
59+
Example Playbook
60+
----------------
61+
62+
Below is an example playbook, say a bootlinux.yml file:
63+
64+
```
65+
---
66+
- hosts: all
67+
roles:
68+
- role: bootlinux
69+
```
70+
71+
Custom runs
72+
===========
73+
74+
Say you want to boot compile a vanilla kernel and you have created a new
75+
section under the hosts file called [dev], with a subset of the [all] section.
76+
You can compile say a vanilla kernel v4.19.58 with an extra set of patches we'd
77+
`git am` for you on top by using the following:
78+
79+
```
80+
cd ansible
81+
ansible-playbook -i hosts -l dev --extra-vars "target_linux_extra_patch=pend-v4.19.58-fixes-20190716-v2.patch" bootlinux.yml
82+
```
83+
84+
You'd place the `pend-v4.19.58-fixes-20190716-v2.patch` file on the directory
85+
`ansible/roles/bootlinux/templates/`.
86+
87+
Now say you wantd to be explicit about a tag of Linux you'd want to use:
88+
89+
```
90+
ansible-playbook -i hosts -l dev --extra-vars "target_linux_ref=v4.19.21 "target_linux_extra_patch=try-v4.19.20-fixes-20190716-v1.patch" bootlinux.yml
91+
```
92+
93+
To uninstall a kernel:
94+
95+
```
96+
ansible-playbook -i hosts -l dev --tags uninstall-linux --extra-vars "uninstall_kernel_ver=4.19.58+" bootlinux.yml
97+
```
98+
99+
To ensure you can get the grub prompt:
100+
101+
```bash
102+
ansible-playbook -i hosts --tags console,vars,manual-update-grub playbooks/bootlinux.yml
103+
```
104+
105+
The ansible bootlinux role relies on the create_partition role to create a data
106+
partition where we can stuff code, and compile it. To test that aspect of
107+
the bootlinux role you can run:
108+
109+
```
110+
ansible-playbook -i hosts -l baseline --tags data_partition,partition bootlinux.yml
111+
```
112+
113+
To reboot all hosts:
114+
115+
```bash
116+
ansible-playbook -i hosts bootlinux.yml --tags reboot
117+
```
118+
119+
For further examples refer to one of this role's users, the
120+
[https://github.com/mcgrof/kdevops](kdevops) project or the
121+
[https://github.com/mcgrof/oscheck](oscheck) project from where
122+
this code originally came from.
123+
124+
# TODO
125+
126+
## Avoiding carrying linux-next configs
127+
128+
It seems a waste of space to be adding configurations for linux-next for all
129+
tags. It seems easier to just look for the latest linux-next and try that.
130+
We just symlink linux-next files when we really need to, and when something
131+
really needs a new config, we then just add a new file.
132+
133+
License
134+
-------
135+
136+
copyleft-next-0.3.1
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SPDX-License-Identifier copyleft-next-0.3.1
2+
---
3+
kdevops_bootlinux: False
4+
infer_uid_and_group: False
5+
6+
data_path: "/data"
7+
data_user: "vagrant"
8+
data_group: "vagrant"
9+
10+
data_device: "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops0"
11+
data_fstype: "xfs"
12+
data_label: "data"
13+
data_fs_opts: "-L {{ disk_setup_label }}"
14+
15+
# Linux target defaults
16+
target_linux_admin_name: "Hacker Amanda"
17+
target_linux_admin_email: "devnull@kernel.org"
18+
target_linux_git: "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
19+
target_linux_shallow_depth: 0
20+
target_linux_tree: "linux-stable"
21+
target_linux_dir_path: "{{ data_path }}/{{ target_linux_tree }}"
22+
kdevops_baseline_and_dev: False
23+
24+
target_linux_ref: "v4.19.133"
25+
target_linux_delta_file:
26+
target_linux_config: "config-{{ target_linux_ref }}"
27+
make: "make"
28+
# Once ansible v2.10 becomes available we can move on to using
29+
# ansible_processor_nproc but that was merged in 2020:
30+
# The commit is 34db57a47f875d11c4068567b9ec7ace174ec4cf
31+
# introduce fact "ansible_processor_nproc": number of usable vcpus #66569
32+
# https://github.com/ansible/ansible/pull/66569
33+
target_linux_make_cmd: "{{ make }} -j{{ ansible_processor_vcpus }}"
34+
target_linux_make_install_cmd: "{{ target_linux_make_cmd }} modules_install install"
35+
36+
uninstall_kernel_enable: False
37+
38+
build_artifacts_dir: "{{ topdir_path }}/workflows/linux/artifacts/"
39+
40+
kdevops_workflow_enable_cxl: False
41+
42+
bootlinux_cxl_test: False
43+
bootlinux_tree_set_by_cli: False
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# Install dependencies for building linux on Debian
3+
4+
- name: Update apt cache
5+
become: yes
6+
become_method: sudo
7+
apt:
8+
update_cache: yes
9+
tags: linux
10+
11+
# apt-get build-dep does not capture all requirements
12+
- name: Install Linux kernel build dependencies
13+
become: yes
14+
become_method: sudo
15+
apt:
16+
name:
17+
- bison
18+
- flex
19+
- git
20+
- gcc
21+
- make
22+
- gawk
23+
- bc
24+
- dump
25+
- indent
26+
- sed
27+
- libssl-dev
28+
- libelf-dev
29+
- liburcu-dev
30+
- xfsprogs
31+
- e2fsprogs
32+
- btrfs-progs
33+
- ntfs-3g
34+
- mdadm
35+
- rpcbind
36+
- portmap
37+
- hwinfo
38+
- open-iscsi
39+
- python3-pip
40+
- zstd
41+
- libncurses-dev
42+
- b4
43+
state: present
44+
tags: linux
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
- name: Enable installation of packages from EPEL
3+
ansible.builtin.include_role:
4+
name: epel-release
5+
when:
6+
- ansible_distribution != "Fedora"
7+
8+
- name: Install packages we care about
9+
become: true
10+
become_method: ansible.builtin.sudo
11+
ansible.builtin.dnf:
12+
update_cache: true
13+
name: "{{ packages }}"
14+
retries: 3
15+
delay: 5
16+
register: result
17+
until: result is succeeded
18+
vars:
19+
packages:
20+
- bison
21+
- flex
22+
- git-core
23+
- e2fsprogs
24+
- xfsprogs
25+
- xfsdump
26+
- lvm2
27+
- gcc
28+
- make
29+
- gawk
30+
- bc
31+
- dump
32+
- libtool
33+
- psmisc
34+
- sed
35+
- vim
36+
- fio
37+
- libaio-devel
38+
- diffutils
39+
- net-tools
40+
- ncurses-devel
41+
- xfsprogs
42+
- e2fsprogs
43+
- elfutils-libelf-devel
44+
- ntfs-3g
45+
- mdadm
46+
- rpcbind
47+
- portmap
48+
- hwinfo
49+
- iscsi-initiator-utils
50+
- openssl
51+
- openssl-devel
52+
- dwarves
53+
- userspace-rcu
54+
- zstd
55+
56+
- name: Install btrfs-progs
57+
become: true
58+
become_method: ansible.builtin.sudo
59+
ansible.builtin.dnf:
60+
update_cache: true
61+
name: "{{ packages }}"
62+
retries: 3
63+
delay: 5
64+
register: result
65+
until: result is succeeded
66+
vars:
67+
packages:
68+
- btrfs-progs
69+
when: ansible_distribution == 'Fedora'
70+
71+
- name: Remove packages that mess with initramfs
72+
become: true
73+
become_method: ansible.builtin.sudo
74+
ansible.builtin.dnf:
75+
state: absent
76+
name: dracut-config-generic
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
- name: Install Linux kernel build dependencies for SUSE sources
3+
become: yes
4+
become_method: sudo
5+
zypper:
6+
name:
7+
- bison
8+
- flex
9+
- git-core
10+
- gcc
11+
- make
12+
- gawk
13+
- bc
14+
- dump
15+
- sed
16+
- libopenssl-devel
17+
- libelf-devel
18+
- liburcu8
19+
- diffutils
20+
- net-tools
21+
- ncurses-devel
22+
- xfsprogs
23+
- e2fsprogs
24+
- btrfsprogs
25+
- ntfs-3g
26+
- mdadm
27+
- rpcbind
28+
- portmap
29+
- hwinfo
30+
- open-iscsi
31+
disable_recommends: no

0 commit comments

Comments
 (0)