ref(playbook): Move all plays into separate directory

This commit is contained in:
Marty Oehme 2025-02-23 10:23:24 +01:00
parent 996560410e
commit 8e79c5f804
Signed by: Marty
GPG key ID: 4E535BC19C61886E
7 changed files with 6 additions and 6 deletions

43
books/host.yaml Normal file
View file

@ -0,0 +1,43 @@
# # The subvol collection seems to be misbehaving?
# # https://github.com/ansible-collections/community.general/issues/7098
# # (and btrfs_subvol module working)
# - name: Create void btrfs subvol
# hosts: host
# vars:
# btrfs_target: 441a90a5-3da2-46ce-9e32-987569b746c9
# mount_dir: /mnt/void
# become: true
# tasks:
# - name: Create @voidroot subvool under root
# community.general.btrfs_subvolume:
# state: present
# name: "/@"
# filesystem_uuid: "{{ btrfs_root_uuid }}"
# # - name: Mount /boot part into voidroot mount
# - name: Mount btrfs subvol into mountdir
# vars:
# boot_dev_uuid:
# ansible.posix.mount:
# src: "{{ item.src }}"
# path: "{{ item.path }}"
# fstype: "{{ item.fstype }}"
# state: mounted
# with_items:
# - { fstype: 'ext4', src: '/dev/mapper/{{ vgname }}-root', path: '{{ mount_dir }}/' }
# # TODO: should take opts from fstab. Definitely needs 'boot' type option
# - { fstype: 'vfat', src: '/dev/disk/by-uuid/{{ boot_dev_uuid }}', path: '{{ mount_dir }}/boot' }
- name: Create voidlinux guest
hosts: hostsystem
become: true
vars:
mount_dir: /mnt/void
tarball_url: "https://repo-default.voidlinux.org/live/current/void-x86_64-ROOTFS-20250202.tar.xz"
tasks:
- name: Unpack rootfs
ansible.builtin.unarchive:
remote_src: yes # we already downloaded it to the 'remote' system
src: "{{ tarball_url }}"
dest: "{{ mount_dir }}"
# ONLY run if this file does not exist (could use any rootfs file to check)
creates: "{{ mount_dir }}/etc/os-release"

133
books/void_base.yaml Normal file
View file

@ -0,0 +1,133 @@
- name: Install void base system
hosts: target_system
become: true
tasks:
# 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
- name: Update xbps and system
community.general.xbps:
name:
- xbps
state: latest
update_cache: true
upgrade: true
- name: Install Base system
community.general.xbps:
name:
- base-system
state: present
- name: Get rid of temporary container metapackage
community.general.xbps:
name:
- base-container-full
state: absent
- name: Install booster
community.general.xbps:
name: booster
state: present
notify: installed-booster
handlers:
- 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
vars:
fname: /boot/booster-void
ansible.builtin.command:
argv:
- booster
- --verbose
- build
- --kernel-version={{ item }}
- "{{ fname }}-{{ item }}.img"
creates: "{{ fname }}-{{ item }}.img"
loop: "{{ kernel_list }}"
listen: installed-booster
- name: Configure void base system
hosts: target_system
become: true
vars:
host_name: voider
timezone: Europe/Berlin
locales_enabled:
- en_US.UTF-8 UTF-8
tasks:
- name: Set hostname
ansible.builtin.template:
src: hostname.tpl
dest: /etc/hostname
- name: Set timezone
ansible.builtin.file:
path: /etc/localtime
src: /usr/share/zoneinfo/{{ timezone }}
state: link
- 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
notify: installed-chrony
- name: Activate acpid service
ansible.builtin.file:
force: "yes"
src: "/etc/sv/acpid"
dest: "/etc/runit/runsvdir/default/acpid"
state: link
handlers:
- name: Regenerate locales
ansible.builtin.command:
argv:
- xbps-reconfigure
- --force
- libc-locales
listen: glibc-locales-changed
- name: Activate chronyd service
ansible.builtin.file:
force: "yes"
src: "/etc/sv/{{ item }}"
dest: "/etc/runit/runsvdir/default/{{ item }}"
state: link
with_items: [chronyd]
listen: installed-chrony

23
books/void_network.yaml Normal file
View file

@ -0,0 +1,23 @@
- name: Set up voidlinux networking
hosts: target_system
become: true
vars:
nameserver1: 9.9.9.9
nameserver2: 9.9.9.10
tasks:
- name: Configure resolv DNS
ansible.builtin.copy:
mode: 0644
dest: "/etc/resolv.conf"
content: |
nameserver {{ nameserver1 }}
nameserver {{ nameserver2 }}
failed_when: false # can't ever fail
- name: Activate dhcp service
ansible.builtin.file:
force: 'yes'
src: "/etc/sv/{{ item }}"
dest: "/etc/runit/runsvdir/default/{{ item }}"
state: link
with_items: [ dhcpcd ]

47
books/void_packages.yaml Normal file
View file

@ -0,0 +1,47 @@
- name: Install basic custom void packages
hosts: interface
become: true
tags: interface
tasks:
- name: Set up keyd for custom key events
community.general.xbps:
name:
- keyd
state: "{{ desired_package_state }}"
notify: installed-keyd
- name: Install many fonts
community.general.xbps:
name: "{{ packages_fonts }}"
state: "{{ desired_package_state }}"
notify: installed-fonts
when: packages_fonts
handlers:
- name: Activate keyd service
ansible.builtin.file:
force: "yes"
src: "/etc/sv/{{ item }}"
dest: "/etc/runit/runsvdir/default/{{ item }}"
state: link
with_items: [keyd]
listen: installed-keyd
- name: Regenerate fontconfig
ansible.builtin.command:
argv:
- xbps-reconfigure
- --force
- fontconfig
listen: installed-fonts
- name: Install basic custom void packages
hosts: target_system
become: true
tags:
- packages
tasks:
- name: Install a bunch of base custom stuff
community.general.xbps:
name: "{{ lookup('community.general.merge_variables', '^packages_.*') }}"
state: "{{ desired_package_state }}"

38
books/void_user.yaml Normal file
View file

@ -0,0 +1,38 @@
- name: Set up primary user
hosts: target_system
become: true
vars:
user_name: marty
user_pass: marty
user_shell: zsh
user_groups:
- wheel
- _seatd # TODO: This will error if it does not exist (seatd not installed)
- audio
- dialout
- disk
- input
- kvm
- lp
- plugdev
- scanner
- storage
- usbmon
- video
tasks:
- name: Enable sudo for "wheel" group
ansible.builtin.lineinfile:
path: "/etc/sudoers"
regexp: '^# %wheel ALL=(ALL) ALL$'
line: '%wheel ALL=(ALL) ALL'
- name: Add user
ansible.builtin.user:
name: "{{ user_name }}"
password: "{{ user_pass | password_hash('sha512', 'supersecretsalt') }}"
create_home: true
shell: "/bin/{{ user_shell }}"
group: "{{ user_name }}"
groups: "{{ user_groups }}"
generate_ssh_key: true

33
books/void_wayland.yaml Normal file
View file

@ -0,0 +1,33 @@
- name: Install void wayland environment
hosts: target_system
become: true
tasks:
- name: Install intel wayland drivers
community.general.xbps:
name:
- mesa-dri
state: present
- name: Install wayland packages
community.general.xbps:
name:
- dbus
- seatd
- turnstile
state: present
# notify: installed-wayland -> TODO: Use handler? Currently using task below
- name: Activate wayland services
ansible.builtin.file:
force: "yes"
src: "/etc/sv/{{ item }}"
dest: "/etc/runit/runsvdir/default/{{ item }}"
state: link
with_items: [dbus, turnstiled, seatd]
- name: Install wlr desktop portals
community.general.xbps:
name:
- xdg-desktop-portal
- xdg-desktop-portal-wlr
state: present