6 Commits
1.0.1 ... 1.0.5

Author SHA1 Message Date
6ed5c0c30a fix(role): Add pacman options to correct config section
Without an [options] or similar INI header line pacman config files
in '/etc/pacman.d' can sometimes load incorrectly, for example when
multiple files exist where some of them do and other do not have the
header. We're normalizing our config file here so that it no longer
trips up pacman.
2025-12-18 22:55:06 +01:00
5c3ed1736e refactor(role): systemctl daemon-reload after copy
Since unit files are now copied to '/etc/systemd/system' we should
make sure that systemd sees the newest version of all unit files
before we attempt to enable a timer unit.
2025-06-04 01:28:57 +02:00
023227fff7 refactor(role): No systemctl daemon-reload on Git pull
Since unit files are now copied to '/etc/systemd/system' merely
cloning or pulling a Git repo no longer warrants a systemctl
daemon-reload.
2025-06-04 01:28:12 +02:00
03b371650c refactor(role): Copy unit files instead of symlinking them
On each target machine we're storing the Git repo that has our unit
files underneath '/opt/git'. Prior to this commit we used to place
symlinks from '/etc/systemd/system' into the appropriate '/opt/git'
subdir. On most machines this worked fine, however, on some we
encountered a race condition on system start.

Sometimes '/opt/git' is not the same file system as '/'. If that's
the case chances are that systemd initializes the system and fails to
access a unit file at '/opt/git' because that file system is just
barely not yet visible early in the boot process.

For a timer unit for example this could result in enabling the unit
and upon reboot seeing that the unit no longer existed in systemd's
world view e.g. via 'systemctl list-timers' even though the symlink
at '/etc/systemd/system' still pointed to an '/opt/git' subdir when
inspected manually seconds after boot. journalctl, however, would
clearly confirm that at system initialization the symlink target was
inaccessible.

We could fiddle around with delaying boot until '/opt/git' and its
descendants are visible but the sane solution is to just not rely on
a separate file system for important stuff such as unit files. We now
copy unit files to '/etc/systemd/system' instead of symlinking them.
2025-06-04 01:26:15 +02:00
33e3ebea6f refactor(role): Move pacman pkg cache underneath boot dataset 2025-04-09 03:15:02 +02:00
b21d28587f refactor(role): Typo 2025-04-07 00:25:50 +02:00
3 changed files with 26 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT
[options]
ILoveCandy
Color
ParallelDownloads = 20
NoExtract = etc/pacman.d/mirrorlist
NoExtract = etc/pacman.d/mirrorlist

View File

@@ -38,24 +38,28 @@
repo: '{{ genvm_os_auto_upgrades_git_repo }}'
dest: '{{ genvm_os_auto_upgrades_git_clone_dir }}'
version: '{{ genvm_os_auto_upgrades_git_branch }}'
- name: 'If Arch Linux copy systemd unit files for OS auto-upgrades to ''/etc/systemd/system'''
when: 'ansible_facts[''os_family''] | lower == ''archlinux'''
loop_control:
loop_var: 'genvm_os_auto_upgrades_unit'
label: 'Copy ''{{ genvm_os_auto_upgrades_unit.source | basename }}'' to ''/etc/systemd/system'''
loop:
- { source: '{{ genvm_os_auto_upgrades_git_clone_dir }}/arch-linux-update-and-restart.service', target: '/etc/systemd/system/arch-linux-update-and-restart.service' }
- { source: '{{ genvm_os_auto_upgrades_git_clone_dir }}/arch-linux-update-and-restart.timer', target: '/etc/systemd/system/arch-linux-update-and-restart.timer' }
ansible.builtin.copy:
src: '{{ genvm_os_auto_upgrades_unit.source }}'
dest: '{{ genvm_os_auto_upgrades_unit.target }}'
remote_src: true
notify:
- 'Reload systemd unit configs'
- name: 'If Arch Linux create symlinks to repo for OS auto-upgrades'
when: 'ansible_facts[''os_family''] | lower == ''archlinux'''
loop_control:
loop_var: 'genvm_os_auto_upgrades_symlink'
label: 'Create symlink to ''{{ genvm_os_auto_upgrades_symlink.target | basename }}'''
loop:
- { target: '{{ genvm_os_auto_upgrades_git_clone_dir }}/arch-linux-update-and-restart.service', symlink: '/etc/systemd/system/arch-linux-update-and-restart.service' }
- { target: '{{ genvm_os_auto_upgrades_git_clone_dir }}/arch-linux-update-and-restart.timer', symlink: '/etc/systemd/system/arch-linux-update-and-restart.timer' }
ansible.builtin.file:
src: '{{ genvm_os_auto_upgrades_symlink.target }}'
dest: '{{ genvm_os_auto_upgrades_symlink.symlink }}'
state: 'link'
force: true
notify:
- 'Reload systemd unit configs'
# Chances are we've just updated systemd unit files in '/etc/systemd/system'. In
# a second we'll be enabling a timer unit that was among those files we just
# (potentially) changed. We should flush our handlers now, i.e. 'systemctl
# daemon-reload' to make sure systemd knows the newest state of our units.
- name: 'Flush handlers'
meta: flush_handlers
- name: 'If Arch Linux enable systemd timer for OS auto-upgrades'
ansible.builtin.systemd_service:

View File

@@ -12,7 +12,7 @@
changed_when: false
failed_when: false
ansible.builtin.shell: |
zfs list zpool/data/var/cache/pacman/pkg
zfs list zpool/root/archlinux/var/cache/pacman/pkg
- name: 'If no pacman cache dataset exists create dataset'
when: 'genvm_archlinux_zfs_pacman_cache_zfs_has_pacman_cache_dataset.rc > 0'
@@ -20,9 +20,9 @@
changed_when: 'genvm_archlinux_zfs_pacman_cache_pacman_cache_dir_was_temp_moved.rc == 0'
ansible.builtin.shell: |
mv '/var/cache/pacman/pkg'{,'.bak'} && \
if ! zfs list zpool/data/var &>/dev/null; then zfs create -o canmount=off zpool/data/var; fi && \
if ! zfs list zpool/data/var/cache &>/dev/null; then zfs create -o canmount=off zpool/data/var/cache; fi && \
if ! zfs list zpool/data/var/cache/pacman &>/dev/null; then zfs create -o canmount=off zpool/data/var/cache/pacman; fi && \
zfs create zpool/data/var/cache/pacman/pkg && \
if ! zfs list zpool/root/archlinux/var &>/dev/null; then zfs create -o canmount=off zpool/root/archlinux/var; fi && \
if ! zfs list zpool/root/archlinux/var/cache &>/dev/null; then zfs create -o canmount=off zpool/root/archlinux/var/cache; fi && \
if ! zfs list zpool/root/archlinux/var/cache/pacman &>/dev/null; then zfs create -o canmount=off zpool/root/archlinux/var/cache/pacman; fi && \
zfs create zpool/root/archlinux/var/cache/pacman/pkg && \
rsync -a --remove-source-files '/var/cache/pacman/pkg'{'.bak',}'/' && \
find '/var/cache/pacman/pkg.bak' -type d -empty -delete