Files
computer-playbook/scripts/tests/deploy/swarm/utils/trigger_units.sh
T
kevinveenbirkenbachandClaude Fable 5 147403a939 refactor(test-swarm): compose node image + ansible provisioning + dir layout
Replace the per-node docker-run bring-up with a single node image
(compose/swarm/Dockerfile bakes python3/dnsmasq/openssh/rsync/cryptsetup)
declared in compose/swarm.yml, one compose up, and one ansible play
(compose/swarm/playbook.yml over ansible_connection: docker) that waits for
systemd, captures IPs, wires lab DNS and installs the .deb per node. Reshape
the harness into topology/ (naming SPOT), routine/ (01_bootstrap + the
sequenced 02-08 steps) and utils/ (clean/, collect/, shared helpers); the
workflow, matrix.py and Makefile follow the new paths. swarm init/join was
already ansible-owned (svc-swarm-node), corrected in the README diagram.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 03:15:52 +02:00

27 lines
967 B
Bash
Executable File

#!/usr/bin/env bash
# Runs in-node. Starts every installed systemd unit matching a pattern.
#
# Arguments:
# $1 PATTERN systemd unit glob (e.g. 'svc-bkp-volume-2-local*.service')
#
# Exit codes: 0 all units completed, 1 a unit failed (journal dumped),
# 2 no unit matches the pattern (caller decides whether that is fatal). The
# `|| true` is load-bearing: list-unit-files exits 1 on an empty glob, and
# under pipefail that would kill the script before the exit-2 contract runs.
set -euo pipefail
PATTERN="${1:?usage: trigger_units.sh PATTERN}"
units="$(systemctl list-unit-files "${PATTERN}" --no-legend | awk '{print $1}' || true)"
[ -n "${units}" ] || exit 2
while read -r unit; do
[ -n "${unit}" ] || continue
echo " starting ${unit} on $(hostname)"
if ! systemctl start "${unit}"; then
echo "FAILURE: ${unit} did not complete on $(hostname); journal:"
journalctl -u "${unit}" --no-pager -n 60 2>/dev/null || true
exit 1
fi
done <<<"${units}"