refactor(bootstrap): restructure package lists to self-contained per-OS dicts with base/extra/conditional

This commit is contained in:
2026-02-21 02:39:06 +01:00
parent e5bd152fb3
commit a76f317f8f
8 changed files with 425 additions and 227 deletions

View File

@@ -1,21 +1,25 @@
---
- name: Bootstrap Alpine Linux
vars:
bootstrap_alpine_packages: >-
_config: "{{ lookup('vars', bootstrap_var_key) }}"
_base_packages: "{{ _config.base | join(' ') }}"
_extra_packages: >-
{{
lookup('vars', bootstrap_var_key) | reject('equalto', '') | join(' ')
((_config.extra | default([])) + (_config.conditional | default([])))
| reject('equalto', '')
| join(' ')
}}
block:
- name: Install Alpine Linux packages
- name: Install Alpine Linux base
ansible.builtin.command: >
apk --root /mnt --no-cache add alpine-base
apk --root /mnt --no-cache add {{ _base_packages }}
register: bootstrap_alpine_bootstrap_result
changed_when: bootstrap_alpine_bootstrap_result.rc == 0
- name: Install extra packages
when: bootstrap_alpine_packages | length > 0
when: _extra_packages | trim | length > 0
ansible.builtin.command: >
apk --root /mnt add {{ bootstrap_alpine_packages }}
apk --root /mnt add {{ _extra_packages }}
register: bootstrap_alpine_extra_result
changed_when: bootstrap_alpine_extra_result.rc == 0