Add Python bootstrap task — auto-installs python3 on Alpine/Debian before gather_facts
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
---
|
||||
- name: Bootstrap — ensure Python is available
|
||||
hosts: linux_hosts
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- ansible.builtin.import_tasks: ../roles/preflight/tasks/bootstrap.yml
|
||||
|
||||
- name: Linux patching
|
||||
hosts: linux_hosts
|
||||
gather_facts: true
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
---
|
||||
- name: Bootstrap — ensure Python is available
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- ansible.builtin.import_tasks: ../roles/preflight/tasks/bootstrap.yml
|
||||
|
||||
- name: Pre-flight safety checks
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
|
||||
18
roles/preflight/tasks/bootstrap.yml
Normal file
18
roles/preflight/tasks/bootstrap.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# 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)
|
||||
ansible.builtin.raw: apk add --no-cache python3
|
||||
when: "'missing' in python_check.stdout"
|
||||
changed_when: true
|
||||
|
||||
- name: Install python3 on Debian/Ubuntu (raw — no Python needed)
|
||||
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'
|
||||
changed_when: true
|
||||
Reference in New Issue
Block a user