Re: [PATCH 09/14] bootlinux: fix os detection for 9p delegated tasks with registered facts
Chuck Lever <[email protected]> Tue, 28 Oct 2025 14:51:48 -0400
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
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? > Register localhost facts to separate variables (localhost_os_family, > localhost_distribution) and refresh target host facts afterward to > ensure both contexts have correct values. Update all OS-specific > conditionals in install-deps to use the localhost_* variables since > packages are installed on the control host, not the target guests. > > Change import_tasks to include_tasks in update-grub since the > conditionals reference runtime facts that aren't available at parse > time. > > Generated-by: Claude AI > Signed-off-by: Daniel Gomez <[email protected]> > --- > playbooks/roles/bootlinux/tasks/build/9p.yml | 18 ++++++++++++++++++ > playbooks/roles/bootlinux/tasks/install-deps/main.yml | 6 +++--- > .../roles/bootlinux/tasks/install-deps/redhat/main.yml | 4 ++-- > playbooks/roles/bootlinux/tasks/update-grub/main.yml | 6 +++--- > 4 files changed, 26 insertions(+), 8 deletions(-) > > diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml > index f390f028..01c95cb7 100644 > --- a/playbooks/roles/bootlinux/tasks/build/9p.yml > +++ b/playbooks/roles/bootlinux/tasks/build/9p.yml > @@ -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 > + > +- name: Refresh target host facts after localhost gathering > + ansible.builtin.setup: > + filter: "ansible_os_family,ansible_distribution,ansible_distribution_version" > + > - name: Install dependencies to build the Linux kernel > delegate_to: localhost > run_once: true > diff --git a/playbooks/roles/bootlinux/tasks/install-deps/main.yml b/playbooks/roles/bootlinux/tasks/install-deps/main.yml > index 51a20741..9a9af005 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" > + - localhost_os_family == "Debian" > > - name: SuSE-specific setup > ansible.builtin.import_tasks: suse/main.yml > when: > - - ansible_os_family == "Suse" > + - localhost_os_family == "Suse" > > - name: Red Hat-specific setup > ansible.builtin.import_tasks: redhat/main.yml > when: > - - ansible_os_family == "RedHat" > + - localhost_os_family == "RedHat" > diff --git a/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml b/playbooks/roles/bootlinux/tasks/install-deps/redhat/main.yml > index 7f1955bf..589b0b18 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" > + - localhost_distribution != "Fedora" > > - name: Install packages we care about > become: true > @@ -67,7 +67,7 @@ > vars: > packages: > - btrfs-progs > - when: ansible_distribution == 'Fedora' > + when: localhost_distribution == 'Fedora' > > - name: Install clang > become: true > diff --git a/playbooks/roles/bootlinux/tasks/update-grub/main.yml b/playbooks/roles/bootlinux/tasks/update-grub/main.yml > index d0455b00..b05996bf 100644 > --- a/playbooks/roles/bootlinux/tasks/update-grub/main.yml > +++ b/playbooks/roles/bootlinux/tasks/update-grub/main.yml > @@ -1,9 +1,9 @@ > --- > # tasks to install update-grub > - name: Distro specific update of your GRUB boot file > - ansible.builtin.import_tasks: debian.yml > + ansible.builtin.include_tasks: debian.yml > when: ansible_facts['os_family']|lower == 'debian' > -- ansible.builtin.import_tasks: suse.yml > +- ansible.builtin.include_tasks: suse.yml > when: ansible_facts['os_family']|lower == 'suse' > -- ansible.builtin.import_tasks: redhat.yml > +- ansible.builtin.include_tasks: redhat.yml > when: ansible_facts['os_family']|lower == 'redhat' > -- Chuck Lever