From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v2 24/33] bootlinux: Add a new builder choice
Date: Sun, 27 Jul 2025 18:14:24 -0700 [thread overview]
Message-ID: <20250728011434.3197091-25-mcgrof@kernel.org> (raw)
In-Reply-To: <20250728011434.3197091-1-mcgrof@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
Currently, for cloud configurations or when 9p is disabled, kdevops
builds the test kernel on each test runner. This is inefficient,
and gets worse as the test matrix for a single kernel version scales
out.
Instead we want to build the test kernel once and make those build
artifacts available for test runners to install. This would be
similar to what KOTD does now, except it does not require setting up
a separate yum repo.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
playbooks/roles/bootlinux/defaults/main.yml | 2 +
.../roles/bootlinux/tasks/build/builder.yml | 228 ++++++++++++++++++
.../tasks/install-deps/redhat/main.yml | 18 ++
playbooks/roles/bootlinux/tasks/main.yml | 6 +
4 files changed, 254 insertions(+)
create mode 100644 playbooks/roles/bootlinux/tasks/build/builder.yml
diff --git a/playbooks/roles/bootlinux/defaults/main.yml b/playbooks/roles/bootlinux/defaults/main.yml
index 4a1ad72e..50ce96bf 100644
--- a/playbooks/roles/bootlinux/defaults/main.yml
+++ b/playbooks/roles/bootlinux/defaults/main.yml
@@ -46,3 +46,5 @@ kdevops_workflow_enable_cxl: False
bootlinux_cxl_test: False
bootlinux_tree_set_by_cli: False
+
+bootlinux_artifacts_dir: "{{ topdir_path }}/workflows/linux/artifacts"
diff --git a/playbooks/roles/bootlinux/tasks/build/builder.yml b/playbooks/roles/bootlinux/tasks/build/builder.yml
new file mode 100644
index 00000000..c8363b8e
--- /dev/null
+++ b/playbooks/roles/bootlinux/tasks/build/builder.yml
@@ -0,0 +1,228 @@
+---
+- name: Install b4
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.pip:
+ name:
+ - b4
+ when:
+ - target_linux_install_b4 is defined
+ - target_linux_install_b4
+ - ansible_os_family == "Debian"
+
+- name: Clone {{ target_linux_tree }}
+ ansible.builtin.git:
+ repo: "{{ target_linux_git }}"
+ dest: "{{ target_linux_dir_path }}"
+ update: true
+ depth: "{{ target_linux_shallow_depth }}"
+ version: "{{ target_linux_ref }}"
+ register: result
+ retries: 3
+ delay: 5
+ until: result is succeeded
+
+- name: Copy the kernel delta to the builder
+ ansible.builtin.template:
+ src: "{{ target_linux_extra_patch }}"
+ dest: "{{ target_linux_dir_path }}/{{ target_linux_extra_patch }}"
+ owner: "{{ data_user }}"
+ group: "{{ data_group }}"
+ mode: "u=rw,g=r,o=r"
+ when:
+ - target_linux_extra_patch is defined
+
+- name: Apply the kernel delta on the builder
+ # noqa: command-instead-of-module
+ ansible.builtin.command:
+ cmd: "git am {{ target_linux_extra_patch }}"
+ chdir: "{{ target_linux_dir_path }}"
+ register: git_am
+ changed_when: not git_am.failed
+ when:
+ - target_linux_extra_patch is defined
+
+- name: Check git user name and email configuration
+ when:
+ - target_linux_apply_patch_message_id is defined
+ - target_linux_apply_patch_message_id | length > 0
+ - bootlinux_b4_am_this_host|bool
+ block:
+ - name: Get the user's git config info
+ community.general.git_config_info:
+ scope: global
+ register: git_user_info
+
+ - name: Set dummy git user email address
+ community.general.git_config:
+ name: user.email
+ scope: global
+ value: "user@example.com"
+ when:
+ - '"user.email" not in git_user_info.config_values'
+
+ - name: Set dummy git user name
+ community.general.git_config:
+ name: user.name
+ scope: global
+ value: "Kdevops User"
+ when:
+ - '"user.name" not in git_user_info.config_values'
+
+- name: Show the message_id
+ ansible.builtin.debug:
+ msg: "{{ target_linux_apply_patch_message_id }}"
+ when:
+ - target_linux_apply_patch_message_id is defined
+
+- name: Apply a message patch set
+ ansible.builtin.shell:
+ chdir: "{{ target_linux_dir_path }}"
+ cmd: |
+ set -o pipefail
+ b4 am -o - {{ target_linux_apply_patch_message_id }} | git am
+ register: b4_am
+ changed_when: not b4_am.failed
+ when:
+ - target_linux_apply_patch_message_id is defined
+ - target_linux_apply_patch_message_id | length > 0
+ - bootlinux_b4_am_this_host|bool
+
+- name: Copy the configuration for kernel {{ target_linux_tree }}
+ ansible.builtin.template:
+ src: "{{ role_path }}/templates/{{ linux_config }}"
+ dest: "{{ target_linux_dir_path }}/.config"
+ owner: "{{ data_user }}"
+ group: "{{ data_group }}"
+ mode: "u=rw,g=r,o=r"
+
+- name: Set the kernel localversion
+ ansible.builtin.lineinfile:
+ path: "{{ target_linux_dir_path }}/localversion"
+ line: "{{ target_linux_localversion }}"
+ mode: "u=rw,g=r,o=r"
+ create: true
+ when:
+ - target_linux_localversion is defined
+ - target_linux_localversion != ""
+
+- name: Configure kernel {{ target_linux_tree }}
+ community.general.make:
+ chdir: "{{ target_linux_dir_path }}"
+ target: "olddefconfig"
+
+- name: Build {{ target_linux_tree }}
+ community.general.make:
+ chdir: "{{ target_linux_dir_path }}"
+ jobs: "{{ ansible_processor_nproc }}"
+ target: "all"
+
+- name: Remove the old artifacts directory on the control host
+ delegate_to: localhost
+ ansible.builtin.file:
+ path: "{{ bootlinux_artifacts_dir }}"
+ state: absent
+
+- name: Ensure an empty artifacts directory exists on the control host
+ delegate_to: localhost
+ run_once: true
+ ansible.builtin.file:
+ path: "{{ bootlinux_artifacts_dir }}"
+ state: directory
+ mode: "u=rwx,g=rx,o=rx"
+
+- name: Build kernel .deb packages
+ when:
+ - ansible_os_family == "Debian"
+ block:
+ - name: Make the bindeb-pkg target
+ community.general.make:
+ chdir: "{{ target_linux_dir_path }}"
+ jobs: "{{ ansible_processor_nproc }}"
+ target: "bindeb-pkg"
+
+ - name: Find the build artifacts
+ ansible.builtin.find:
+ paths: "{{ artifact_paths }}"
+ patterns: "*.deb"
+ file_type: file
+ recurse: true
+ register: found_debs
+
+ - name: Fetch the build artifacts to the control host
+ ansible.builtin.fetch:
+ src: "{{ item.path }}"
+ dest: "{{ bootlinux_artifacts_dir }}/"
+ flat: true
+ loop: "{{ found_debs.files }}"
+ loop_control:
+ label: "Fetching {{ item.path | basename }} ..."
+
+- name: Build kernel .rpm packages
+ when:
+ - ansible_os_family != "Debian"
+ block:
+ - name: Build the list of artifacts directories on the builder
+ ansible.builtin.set_fact:
+ artifact_paths:
+ - "{{ target_linux_dir_path }}/rpmbuild/RPMS"
+ - "{{ ansible_env.HOME }}/rpmbuild/RPMS"
+
+ - name: Wipe the artifact directories on the builder
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: absent
+ loop: "{{ artifact_paths }}"
+ loop_control:
+ label: "Deleting {{ item }} ..."
+
+ - name: Create empty artifact directories on the builder
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: directory
+ mode: "u=rwx,g=rx,o=rx"
+ loop: "{{ artifact_paths }}"
+ loop_control:
+ label: "Creating {{ item }} ..."
+
+ - name: Make the binrpm-pkg target
+ community.general.make:
+ chdir: "{{ target_linux_dir_path }}"
+ jobs: "{{ ansible_processor_nproc }}"
+ target: "binrpm-pkg"
+ params:
+ RPMOPTS: '--without devel'
+
+ - name: Find the build artifacts
+ ansible.builtin.find:
+ paths: "{{ artifact_paths }}"
+ patterns: "*.rpm"
+ file_type: file
+ recurse: true
+ register: found_rpms
+
+ - name: Fetch the build artifacts to the control host
+ ansible.builtin.fetch:
+ src: "{{ item.path }}"
+ dest: "{{ bootlinux_artifacts_dir }}/"
+ flat: true
+ loop: "{{ found_rpms.files }}"
+ loop_control:
+ label: "Fetching {{ item.path | basename }} ..."
+
+- name: Extract the release information of the built kernel
+ community.general.make:
+ chdir: "{{ target_linux_dir_path }}"
+ target: "kernelrelease"
+ register: kernelrelease
+
+- name: Store the kernel release information with the build artifacts
+ delegate_to: localhost
+ ansible.builtin.lineinfile:
+ create: true
+ line: "{{ kernelrelease.stdout }}"
+ mode: "u=rw,g=r,o=r"
+ path: "{{ bootlinux_artifacts_dir }}/kernel.release"
+
+- name: Skip the kernel install steps
+ ansible.builtin.meta: end_play
diff --git a/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml b/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
index 7849f6f3..0f966d67 100644
--- a/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
+++ b/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
@@ -68,6 +68,24 @@
- btrfs-progs
when: ansible_distribution == 'Fedora'
+- name: Install rpmbuild
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.dnf:
+ name:
+ - elfutils-devel
+ - perl-core
+ - rpm-build
+ - rsync
+ state: present
+ update_cache: true
+ retries: 3
+ delay: 5
+ register: rpmbuild_result
+ until: rpmbuild_result is succeeded
+ when:
+ - bootlinux_builder|bool
+
- name: Remove packages that mess with initramfs
become: yes
become_method: sudo
diff --git a/playbooks/roles/bootlinux/tasks/main.yml b/playbooks/roles/bootlinux/tasks/main.yml
index 62a081a9..57564399 100644
--- a/playbooks/roles/bootlinux/tasks/main.yml
+++ b/playbooks/roles/bootlinux/tasks/main.yml
@@ -80,6 +80,12 @@
when:
- bootlinux_targets|bool
+- name: Build kernel on the builder node
+ ansible.builtin.include_tasks:
+ file: "{{ role_path }}/tasks/build/builder.yml"
+ when:
+ - bootlinux_builder|bool
+
- name: Run uname before
command: "uname -r"
register: uname_cmd_before
--
2.47.2
next prev parent reply other threads:[~2025-07-28 1:14 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 1:14 [PATCH v2 00/33] remove vagrant and bootlinux shape up Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 01/33] vagrant: remove entire vagrant configuration directory Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 02/33] kconfigs: fix Kconfig references after vagrant removal Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 03/33] scripts: remove Vagrant-specific scripts and Makefiles Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 04/33] playbooks: remove Vagrant-specific playbooks and roles Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 05/33] gitignore: remove Vagrant-specific ignore patterns Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 06/33] docs: remove Vagrant-specific documentation files Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 07/33] Remove all remaining Vagrant references from codebase Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 08/33] terraform: Clean up the destroy tasks Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 09/33] Switch to the cloud.terraform.terraform module Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 10/33] terraform: Make use of the new "terraform_output" module Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 11/33] terraform: Move "wait_for_connection" out of the terraform playbook Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 12/33] terraform: Remove "delegate_to: localhost" Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 13/33] terraform: Replace scripts/status_terraform.sh Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 14/33] Kconfig: Convert the 9p option to a choice menu Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 15/33] bootlinux: fix making 9p default if using libvirt Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 16/33] bootlinux: Relocate tasks that select a kernel .config Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 17/33] bootlinux: Simplify tasks that select the kernel .config to build Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 18/33] bootlinux: Select the kernel .config earlier Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 19/33] bootlinux: Move 9p build tasks to a subrole Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 20/33] bootlinux: Move tasks for building on target nodes " Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 21/33] bootlinux: Clean up a grub set-up task Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 22/33] bootlinux: Harden update-grub/install.yml Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 23/33] Add a guest/instance for building the test kernel Luis Chamberlain
2025-07-28 1:14 ` Luis Chamberlain [this message]
2025-07-28 1:14 ` [PATCH v2 25/33] workflows: Add a kconfig setting for installing kernels via package Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 26/33] bootlinux: Enclose tasks to find kernel release name in a block: Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 27/33] bootlinux: Pick up kernel release info for pre-built packages Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 28/33] bootlinux: Install pre-built kernels from packages Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 29/33] bootlinux: Add an option to build with clang instead of gcc Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 30/33] Makefile: add make style for style checking Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 31/33] CLAUDE.md: new workflow guide for hosts and nodes Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 32/33] CLAUDE.md: add don't BS rules Luis Chamberlain
2025-07-28 1:14 ` [PATCH v2 33/33] gen_nodes/gen_hosts: avoid usage of fs_config_path on task names Luis Chamberlain
2025-07-29 20:07 ` [PATCH v2 00/33] remove vagrant and bootlinux shape up Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250728011434.3197091-25-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox