Re: [PATCH v2 09/15] bootlinux: fix os detection for 9p build dependency installation

Chuck Lever <[email protected]> Fri, 7 Nov 2025 14:22:58 -0500
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
On 10/29/25 8:40 AM, Daniel Gomez wrote:
> From: Daniel Gomez <[email protected]>
> 
> Dependency installation for 9P builds was checking ansible_os_family,
> which references the target guest's OS instead of the control host where
> packages are actually installed. This caused incorrect packages to be
> installed when building Fedora guests on Debian hosts.
> 
> Replace ansible_os_family checks with Kconfig distro variables
> (distro_debian_based, distro_fedora, etc.) which correctly detect
> the control host's distribution. Add fallback defaults to ensure the
> variables are always defined for standalone role usage.
> 
> Generated-by: Claude AI
> Suggested-by: Chuck Lever <[email protected]>

Hrm. I might not have understood the whole picture.

Yes, distro_yada_based does pick the controller's OS version.
But so does ansible_os_family when the task is running on
localhost.

I just hit a problem with the "build linux on a separate
target node" configuration, where the target is running
Debian 11 and the controller is running Fedora 41. The
bootlinux install-deps/main.yml checks were coming to
the wrong conclusion.

So if build.yml was running on the controller, then
ansible_os_family should have been "Debian" for you.
Question is, where was it running? For 9p, I'll bet it
was running on the targets; it might need to run on
both localhost and the targets in this case.


> Signed-off-by: Daniel Gomez <[email protected]>
> ---
>  playbooks/roles/bootlinux/defaults/main.yml                  | 6 ++++++
>  playbooks/roles/bootlinux/tasks/build/9p.yml                 | 2 +-
>  playbooks/roles/bootlinux/tasks/install-deps/main.yml        | 6 +++---
>  playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml | 4 ++--
>  4 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/playbooks/roles/bootlinux/defaults/main.yml b/playbooks/roles/bootlinux/defaults/main.yml
> index 1ae70b2c..78e4e28f 100644
> --- a/playbooks/roles/bootlinux/defaults/main.yml
> +++ b/playbooks/roles/bootlinux/defaults/main.yml
> @@ -141,3 +141,9 @@ bootlinux_fragment_x86: false
>  bootlinux_fragment_xarray: false
>  bootlinux_fragment_xarray_no_multi: false
>  
> +
> +# Distro controls
> +distro_debian_based: false
> +distro_fedora: false
> +distro_redhat_based: false
> +distro_suse_based: false
> diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml
> index f390f028..809d342a 100644
> --- a/playbooks/roles/bootlinux/tasks/build/9p.yml
> +++ b/playbooks/roles/bootlinux/tasks/build/9p.yml
> @@ -14,7 +14,7 @@
>    when:
>      - target_linux_install_b4 is defined
>      - target_linux_install_b4
> -    - ansible_facts['os_family']|lower != 'debian'
> +    - not distro_debian_based|bool
>    run_once: true
>    delegate_to: localhost
>  
> diff --git a/playbooks/roles/bootlinux/tasks/install-deps/main.yml b/playbooks/roles/bootlinux/tasks/install-deps/main.yml
> index 51a20741..058f3926 100644
> --- a/playbooks/roles/bootlinux/tasks/install-deps/main.yml
> +++ b/playbooks/roles/bootlinux/tasks/install-deps/main.yml
> @@ -2,14 +2,14 @@
>  - name: Debian-specific setup
>    ansible.builtin.import_tasks: debian/main.yml
>    when:
> -    - ansible_os_family == "Debian"
> +    - distro_debian_based|bool
>  
>  - name: SuSE-specific setup
>    ansible.builtin.import_tasks: suse/main.yml
>    when:
> -    - ansible_os_family == "Suse"
> +    - distro_suse_based|bool
>  
>  - name: Red Hat-specific setup
>    ansible.builtin.import_tasks: redhat/main.yml
>    when:
> -    - ansible_os_family == "RedHat"
> +    - distro_redhat_based|bool
> diff --git a/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml b/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
> index 7f1955bf..e9a0c6e2 100644
> --- a/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
> +++ b/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml
> @@ -3,7 +3,7 @@
>    ansible.builtin.include_role:
>      name: epel-release
>    when:
> -    - ansible_distribution != "Fedora"
> +    - not distro_fedora|bool
>  
>  - name: Install packages we care about
>    become: true
> @@ -67,7 +67,7 @@
>    vars:
>      packages:
>        - btrfs-progs
> -  when: ansible_distribution == 'Fedora'
> +  when: distro_fedora|bool
>  
>  - name: Install clang
>    become: true
> 


-- 
Chuck Lever