From 964b2a79091a989f59fb1b4fd18432a9256b6a06 Mon Sep 17 00:00:00 2001 From: Semaphore Date: Wed, 11 Mar 2026 10:41:35 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20bootstrap=20OS=20detection=20=E2=80=94=20?= =?UTF-8?q?use=20/etc/os-release=20instead=20of=20ansible=5Fos=5Ffamily?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/preflight/tasks/bootstrap.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/roles/preflight/tasks/bootstrap.yml b/roles/preflight/tasks/bootstrap.yml index d9a389a..30a2592 100644 --- a/roles/preflight/tasks/bootstrap.yml +++ b/roles/preflight/tasks/bootstrap.yml @@ -1,18 +1,25 @@ --- -# Runs before gather_facts using raw commands — no Python required - name: Check if python3 is installed ansible.builtin.raw: which python3 || echo "missing" register: python_check changed_when: false -- name: Install python3 on Alpine (raw — no Python needed) +- name: Check OS type for bootstrap + ansible.builtin.raw: cat /etc/os-release | grep ^ID= | cut -d= -f2 | tr -d '"' + register: os_id + changed_when: false + +- name: Install python3 on Alpine ansible.builtin.raw: apk add --no-cache python3 - when: "'missing' in python_check.stdout" + when: "'missing' in python_check.stdout and 'alpine' in os_id.stdout" changed_when: true -- name: Install python3 on Debian/Ubuntu (raw — no Python needed) +- name: Install python3 on Debian/Ubuntu ansible.builtin.raw: apt-get install -y python3 - when: - - "'missing' in python_check.stdout" - - ansible_os_family is not defined or ansible_os_family == 'Debian' + when: "'missing' in python_check.stdout and ('debian' in os_id.stdout or 'ubuntu' in os_id.stdout)" + changed_when: true + +- name: Install python3 on RHEL/CentOS + ansible.builtin.raw: dnf install -y python3 || yum install -y python3 + when: "'missing' in python_check.stdout and ('rhel' in os_id.stdout or 'centos' in os_id.stdout or 'fedora' in os_id.stdout)" changed_when: true