[PATCH v2 10/15] selftests: fix os detection for 9p build dependency installation
Daniel Gomez <[email protected]> Wed, 29 Oct 2025 13:40:52 +0100
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> The selftests role calls install-deps twice: once on the target guest and once on localhost for 9P builds. When delegated to localhost, ansible_facts still references the target guest's OS rather than the control host's OS, causing the wrong package manager to be invoked (e.g., dnf on Debian hosts when building Fedora guests). Split install-deps into two separate files: main.yml uses ansible_facts for detecting the guest OS in normal execution, while main-localhost.yml uses Kconfig distro variables for detecting the control host OS when delegated to localhost. Add distro variable fallbacks to defaults/main.yml to ensure the Kconfig variables are always defined when the role runs. This prevents "Could not detect which major revision of dnf is in use" errors when building Fedora guests on Debian control hosts with 9P. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- playbooks/roles/selftests/defaults/main.yml | 6 ++++++ .../roles/selftests/tasks/install-deps/main-localhost.yml | 10 ++++++++++ playbooks/roles/selftests/tasks/main.yml | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/playbooks/roles/selftests/defaults/main.yml b/playbooks/roles/selftests/defaults/main.yml index 45cb5022..21623690 100644 --- a/playbooks/roles/selftests/defaults/main.yml +++ b/playbooks/roles/selftests/defaults/main.yml @@ -37,3 +37,9 @@ selftest_kernelspace: false selftest_xarray: false selftest_maple: false selftest_vma: false + +# Distro controls +distro_debian_based: false +distro_fedora: false +distro_redhat_based: false +distro_suse_based: false diff --git a/playbooks/roles/selftests/tasks/install-deps/main-localhost.yml b/playbooks/roles/selftests/tasks/install-deps/main-localhost.yml new file mode 100644 index 00000000..4817f530 --- /dev/null +++ b/playbooks/roles/selftests/tasks/install-deps/main-localhost.yml @@ -0,0 +1,10 @@ +--- +# tasks to install dependencies for selftests on localhost (for 9P builds) +# Uses Kconfig distro variables instead of ansible_facts to detect control host OS +- name: Debian-specific setup for localhost + ansible.builtin.import_tasks: tasks/install-deps/debian/main.yml + when: distro_debian_based|bool +- ansible.builtin.import_tasks: tasks/install-deps/suse/main.yml + when: distro_suse_based|bool +- ansible.builtin.import_tasks: tasks/install-deps/redhat/main.yml + when: distro_redhat_based|bool diff --git a/playbooks/roles/selftests/tasks/main.yml b/playbooks/roles/selftests/tasks/main.yml index f8af3080..3f5e0319 100644 --- a/playbooks/roles/selftests/tasks/main.yml +++ b/playbooks/roles/selftests/tasks/main.yml @@ -19,7 +19,7 @@ - name: Install dependencies to build Linux selftests on host tags: ["deps"] run_once: true - ansible.builtin.import_tasks: install-deps/main.yml + ansible.builtin.import_tasks: install-deps/main-localhost.yml delegate_to: localhost when: - bootlinux_9p|bool -- 2.51.0