ref(playbook): Change to role-based structure

This commit is contained in:
Marty Oehme 2025-02-28 20:57:34 +01:00
parent 95fd68bed8
commit b3b280fbe4
Signed by: Marty
GPG key ID: 4E535BC19C61886E
39 changed files with 635 additions and 601 deletions

View file

@ -0,0 +1,31 @@
- name: List kernel module dirs
ansible.builtin.find:
paths: "/usr/lib/modules"
file_type: directory
register: found_kernels
listen: installed-booster
- name: Find kernels
ansible.builtin.set_fact:
kernel_list: "{{ found_kernels['files'] | map(attribute='path') | map('regex_replace', '^.*/(.*)$', '\\1') | list }}"
listen: installed-booster
- name: Create booster initramfs
ansible.builtin.command:
argv:
- booster
- --verbose
- build
- --kernel-version={{ item }}
- "{{ fname }}-{{ item }}.img"
creates: "{{ fname }}-{{ item }}.img"
loop: "{{ kernel_list }}"
listen: installed-booster
- name: Regenerate locales
ansible.builtin.command:
argv:
- xbps-reconfigure
- --force
- libc-locales
listen: glibc-locales-changed

122
roles/base/tasks/main.yaml Normal file
View file

@ -0,0 +1,122 @@
# Prefer booster to dracut so make sure to never install it
- name: Ignore dracut
ansible.builtin.lineinfile:
path: /etc/xbps.d/ignore-dracut.conf
line: ignorepkg=dracut
state: present
create: true # create file if absent
tags:
- packages
- dracut
- name: Update xbps and system
community.general.xbps:
name:
- xbps
state: latest
update_cache: true
upgrade: true
tags:
- packages
- update
- name: Install Base system
community.general.xbps:
name:
- base-system
state: present
tags:
- packages
- name: Get rid of temporary container metapackage
community.general.xbps:
name:
- base-container-full
state: absent
tags:
- packages
- name: Install booster
community.general.xbps:
name: booster
state: present
notify: installed-booster
tags:
- packages
- booster
- name: Set hostname
ansible.builtin.template:
src: hostname.j2
dest: /etc/hostname
tags: hostname
- name: Set timezone
ansible.builtin.file:
path: /etc/localtime
src: /usr/share/zoneinfo/{{ timezone }}
state: link
tags: timezone
- name: Install glibc
tags: glibc
block:
- name: Check if glibc locales exist
ansible.builtin.stat:
path: /etc/default/libc-locales
register: libc_locales_file
- name: Set correct glibc locales
ansible.builtin.lineinfile:
path: /etc/default/libc-locales
regexp: "^{{ item }}"
line: "{{ item }}"
state: present
create: true
loop: "{{ locales_enabled }}"
when: libc_locales_file.stat.exists
notify: glibc-locales-changed
- name: Set up chrony for NTP management
community.general.xbps:
name:
- chrony
state: present
tags: chrony
- name: Activate chronyd service
ansible.builtin.file:
src: "/etc/sv/chronyd"
dest: "/etc/runit/runsvdir/default/chronyd"
state: link
tags: chrony
- name: Activate acpid service
ansible.builtin.file:
src: "/etc/sv/acpid"
dest: "/etc/runit/runsvdir/default/acpid"
state: link
tags: acpid
- name: Set up snooze as cron daemon
tags:
- cron
- snooze
block:
- name: Install snooze
community.general.xbps:
name:
- snooze
state: present
- name: Activate snooze cron services
ansible.builtin.file:
force: "yes"
src: "/etc/sv/{{ item }}"
dest: "/etc/runit/runsvdir/default/{{ item }}"
state: link
loop:
- snooze-hourly
- snooze-daily
- snooze-weekly
- snooze-monthly

View file

@ -0,0 +1 @@
{{ host_name }}

View file

@ -0,0 +1,6 @@
---
booster_initramfs_name: /boot/booster-void
host_name: voider
timezone: Europe/Berlin
locales_enabled:
- en_US.UTF-8 UTF-8