· about 25 minutes · runs on ubuntu-26.04-automation · unrated
An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.
/opt/etl/report.py pulls metrics from the internal metrics API and writes a summary to
/var/lib/etl/reports/latest.json. Its author says it works: they run it from /opt/etl, with
the project's virtualenv activated, and the report appears.
From its systemd timer it has never produced a single report. The timer is supposed to run it shortly after boot and every five minutes after that.
Security also flagged the metrics API token in /etc/etl/token.
What is expected, and graded:
etl-report.timer is enabled and active, so it survives reboots.etl service account, not as root.You have root through sudo. Everything must still hold after a reboot.
The machine is checked, rebooted, and checked again. A check passes only if it passes both times.
| Check | Objective |
|---|---|
| 01_timer_enabled | Schedule a job with a systemd timer that survives reboots |
| 02_job_succeeds_unattended | Run a Python job from systemd with the project's own virtual environment |
| 03_runs_as_etl | Run automation as a dedicated service account with least privilege |
| 04_token_protected | Run automation as a dedicated service account with least privilege |
Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).
man 5 systemd.timerman 5 systemd.exec4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:
How does a systemd unit run a script with a virtual environment's packages?
ExecStart= names the venv's interpreter, e.g. /opt/etl/.venv/bin/python /opt/etl/report.py
A venv is selected by which interpreter executable starts, through the pyvenv.cfg beside it. activate only edits the shell's PATH and prompt, and an ExecStartPre runs in a separate process anyway; setting VIRTUAL_ENV alone changes nothing about which python runs.
https://docs.python.org/3/library/venv.html
A script opens `config/settings.json` and fails only when systemd runs it. What is the likeliest cause?
A system unit starts in / unless WorkingDirectory= is set, so the relative path points elsewhere
Relative paths resolve against the current directory, which for a system service is / by default. Set WorkingDirectory=, or better resolve paths relative to the script with Path(__file__).
man 5 systemd.exec (WorkingDirectory=)
Which unit do you enable so a scheduled job survives reboots?
The .timer unit
The timer is WantedBy=timers.target and starts the service when due. A service run by a timer usually has no [Install] section; forcing it into multi-user.target makes it run once at boot as well.
man 5 systemd.timer