Re: [PATCH 09/14] bootlinux: fix os detection for 9p delegated tasks with registered facts

Daniel Gomez <[email protected]> Tue, 28 Oct 2025 20:53:54 +0100
Newsgroups dev.linux.lists.kdevops
Organization kernel.org
Message-ID <[email protected]>
On 28/10/2025 19.51, Chuck Lever wrote:
> On 10/28/25 2:11 PM, Daniel Gomez wrote:
>> From: Daniel Gomez <[email protected]>
>>
>> When using 9P builds, the Linux kernel is built once on the control
>> host (delegate_to: localhost, run_once: true) and shared to all guests.
>> The dependency installation tasks reference ansible_os_family which
>> gets overwritten when gathering facts from localhost, causing the wrong
>> distribution's packages to be installed.
> 
> Just curious: Doesn't kdevops already have variables (eg, distro_debian)
> that contain this state?

You're spot on.

To be clear, I don't like this approach, but I couldn't "gather"
ansible_os_family from the localhost and use it directly. The reason is because
of the inventory scope we run this playbook on:

Example:

make linux
...
+ ansible-playbook --limit baseline:dev playbooks/bootlinux.yml \
'--extra-vars=target_linux_git=/mirror/linux.git target_linux_tree=linux \
target_linux_ref=v6.15...
==> [linux]
PLAY: BOOTLINUX
TASK: Gathering Facts [kci-18884852820-153-nvme]
⠀⠀✓ [kci-18884852820-153-nvme]
TASK: Import optional extra_args file [kci-18884852820-153-nvme]
⠀⠀✓ [kci-18884852820-153-nvme]
TASK: Select the .config file for building the test kernel [kci-18884852820-153-nvme]
⠀⠀✓ [kci-18884852820-153-nvme]
...

That is gathering facts for the baseline and dev groups. Adding localhost (or
all hosts) shouldn't work either, since we don't want the playbook to run on the
localhost (controller node), except for some specific tasks. My guess is that it
worked before because the guest and the localhost (controller node) happened to
match, but we weren't actually collecting the controller node's facts correctly.

That gets me thinking if we should run bootlinux.yml localhosts tasks first with
a tag (e.g. setup), then run bootlinux on baseline and dev. Or what do you think
would be the right approach? 


>> @@ -1,4 +1,22 @@
>>  ---
>> +- name: Gather facts from localhost for dependency installation
>> +  ansible.builtin.setup:
>> +    filter: "ansible_os_family,ansible_distribution"
>> +  delegate_to: localhost
>> +  register: localhost_facts
>> +  run_once: true
>> +
>> +- name: Set localhost OS facts for 9P build
>> +  ansible.builtin.set_fact:
>> +    localhost_os_family: "{{ localhost_facts.ansible_facts.ansible_os_family }}"
>> +    localhost_distribution: "{{ localhost_facts.ansible_facts.ansible_distribution }}"
>> +  delegate_to: localhost
>> +  run_once: true