Files
computer-playbook/roles/svc-bkp-loc-2-usb
Kevin Veen-Birkenbach 716ebef33b Refactor task includes and update variable handling for Ansible 2.20 migration
This commit updates multiple roles to ensure compatibility with Ansible 2.20.
Several include paths and task-loading mechanisms required adjustments,
as Ansible 2.20 applies stricter evaluation rules for complex Jinja expressions
and no longer resolves certain relative include paths the way Ansible 2.18 did.

Key changes:
- Replaced legacy once_finalize.yml and once_flag.yml with the new structure
  under tasks/utils/once/finalize.yml and tasks/utils/once/flag.yml.
- Updated all include_tasks statements to use 'path_join' with playbook_dir,
  ensuring deterministic and absolute file resolution across roles.
- Fixed all network helper includes by converting direct relative paths such as
  'roles/docker-compose/tasks/utils/network.yml' to proper Jinja-evaluated paths.
- Normalized MATOMO_* variable names for consistency with the updated variable
  scope behavior in Ansible 2.20.
- Removed deprecated patterns that were implicitly supported in Ansible 2.18
  but break under the more strict variable and path resolution model in 2.20.

These changes are part of the full migration step required to ensure the
infinito-nexus roles remain stable, deterministic, and forward-compatible with
Ansible 2.20.

Details of the discussion and reasoning can be found in this conversation:
https://chatgpt.com/share/69300a8d-24d4-800f-bec0-e895a695618a
2025-12-03 11:02:34 +01:00
..

Backup to USB

Description

This Ansible role automates backups to a removable USB device on Arch Linux systems. It ensures that a custom Python backup script is deployed, the necessary systemd units are configured, and backups are triggered whenever the specified USB mount point becomes available.

Overview

Designed for Arch Linux, this role validates configuration variables (mount, target, source), installs the backup script, generates a systemd service, and sets up a corresponding mount unit. When the USB device is mounted, the service runs the script to synchronize files from the source directory to the USB target, preserving previous snapshots via hard links.

Purpose

The purpose of this role is to provide a reliable, idempotent solution for local backups to a swappable USB drive. By automating the entire workflow—from variable checks and script deployment to service orchestration and snapshot management—it reduces manual intervention and integrates seamlessly with other Infinito.Nexus roles for comprehensive system automation.

Features

  • Configuration Validation: Fails early if any of backup_to_usb_mount, backup_to_usb_target, or backup_to_usb_source is empty.
  • Script Deployment: Copies the svc-bkp-loc-2-usb.py backup script to the target path with correct ownership and permissions.
  • Systemd Integration: Generates and installs a systemd mount unit for the USB device and a oneshot service that triggers backup upon mount.
  • Snapshot Backups: Uses rsync --link-dest to create incremental snapshots and preserve previous versions without duplicating unchanged files.
  • Idempotent Runs: Ensures tasks only run when needed and leverages Ansibles assert and state management for consistent behavior.
  • Service Reload Handlers: Automatically reloads the systemd service when template changes occur.

Credits

Developed and maintained by Kevin Veen-Birkenbach. Visit veen.world for more information.

Part of the Infinito.Nexus Project License: Infinito.Nexus NonCommercial License