[PATCH] bootlinux: fix 9p install-deps OS dispatch

Daniel Gomez <[email protected]> Tue, 19 May 2026 15:46:54 +0200
Newsgroups dev.linux.lists.kdevops
Message-ID <20260519-b4-bootlinux-9p-install-deps-fix-v1-1-1bb5ab03d0b3@samsung.com>
From: Daniel Gomez <[email protected]>

The 9p build path delegates install-deps to localhost but the
install-deps dispatcher consults ansible_os_family, which under
delegate_to resolves to the play target's facts (the guest), not
the delegate's. On a Debian controller with a Fedora guest the
RedHat branch runs and dnf executes on the Debian controller.

Gather localhost's facts via delegate_facts: true and dispatch
three explicit per-distro imports off hostvars['localhost']. The
same lookup replaces the equivalent expression on the b4
pip-install skip immediately below.

Commit 0e9c8ac8bc68 attempted the same fix via a Kconfig-derived
distro flag and was reverted because it broke the builder and
target sub-roles. This patch confines the controller-side lookup
to the 9p tasks that already delegate to localhost; per-node
paths are untouched.

Reported-by: Chuck Lever <[email protected]>
Link: https://lore.kernel.org/kdevops/[email protected]/
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <[email protected]>
---
The bootlinux/build/9p.yml path delegates install-deps to localhost
without giving the dispatcher access to the controller's facts, so on
a heterogeneous controller + guest pair (e.g. Debian controller, Fedora
guest) ansible_os_family resolves to the guest's value and the wrong
package manager runs on the controller.

Confines the controller-side lookup to the 9p tasks that already
delegate to localhost, using delegate_facts: true + hostvars to read
localhost's facts explicitly. Per-node paths are untouched, so the
revert hazard that hit commit 0e9c8ac8bc68 (which broke the builder
and target sub-roles by mixing controller-only and per-node distro
detection) does not apply.

This series depends on the "treewide: add SPDX-License-Identifier
headers" series.
---
 playbooks/roles/bootlinux/tasks/build/9p.yml | 33 ++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml
index dbc7d7c9..26f027bf 100644
--- a/playbooks/roles/bootlinux/tasks/build/9p.yml
+++ b/playbooks/roles/bootlinux/tasks/build/9p.yml
@@ -1,10 +1,35 @@
 ---
 # SPDX-License-Identifier: copyleft-next-0.3.1
-- name: Install dependencies to build the Linux kernel
+# install-deps must run on the controller (delegate_to: localhost) and
+# dispatch by the controller's distribution. A `delegate_to: localhost`
+# task that consults ansible_os_family evaluates the play target's
+# facts (the guest), not the delegate's, so on a Debian controller
+# with a Fedora guest the redhat dispatcher would run dnf on the
+# Debian host. Gather localhost's facts via delegate_facts: true and
+# dispatch off hostvars['localhost'].
+- name: Gather controller facts for 9p install-deps dispatch
+  ansible.builtin.setup:
   delegate_to: localhost
+  delegate_facts: true
   run_once: true
-  ansible.builtin.import_tasks:
-    file: install-deps/main.yml
+
+- name: Install kernel build dependencies on the controller (Debian)
+  ansible.builtin.import_tasks: install-deps/debian/main.yml
+  delegate_to: localhost
+  run_once: true
+  when: hostvars['localhost']['ansible_os_family'] == "Debian"
+
+- name: Install kernel build dependencies on the controller (SUSE)
+  ansible.builtin.import_tasks: install-deps/suse/main.yml
+  delegate_to: localhost
+  run_once: true
+  when: hostvars['localhost']['ansible_os_family'] == "Suse"
+
+- name: Install kernel build dependencies on the controller (Red Hat)
+  ansible.builtin.import_tasks: install-deps/redhat/main.yml
+  delegate_to: localhost
+  run_once: true
+  when: hostvars['localhost']['ansible_os_family'] == "RedHat"
 
 - name: Install b4 on host
   become: true
@@ -15,7 +40,7 @@
   when:
     - target_linux_install_b4 is defined
     - target_linux_install_b4
-    - ansible_facts['os_family']|lower != 'debian'
+    - hostvars['localhost']['ansible_os_family'] != "Debian"
   run_once: true
   delegate_to: localhost
 

---
base-commit: 83c7dfdf33f790787972fdc569d0889da853cdb8
change-id: 20260518-b4-bootlinux-9p-install-deps-fix-06a71b3ecb9a

Best regards,
--  
Daniel Gomez <[email protected]>