[ norboten ]
automation · lab py-01

The Job That Works on My Machine

· 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.

The briefing

/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:

  1. etl-report.timer is enabled and active, so it survives reboots.
  2. The job succeeds when systemd runs it — without anyone logged in — and writes a fresh report.
  3. It runs as the etl service account, not as root.
  4. The token is readable by that account and nobody else.

You have root through sudo. Everything must still hold after a reboot.

What is graded

The machine is checked, rebooted, and checked again. A check passes only if it passes both times.

CheckObjective
01_timer_enabledSchedule a job with a systemd timer that survives reboots
02_job_succeeds_unattendedRun a Python job from systemd with the project's own virtual environment
03_runs_as_etlRun automation as a dedicated service account with least privilege
04_token_protectedRun automation as a dedicated service account with least privilege

Start it

  1. 2Labs
  2. py-01select this one
  3. udownload it
  4. sstart the machine

Reading

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).

Theory for this lab

4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:

Question 1

How does a systemd unit run a script with a virtual environment's packages?

Question 2

A script opens `config/settings.json` and fails only when systemd runs it. What is the likeliest cause?

Question 3

Which unit do you enable so a scheduled job survives reboots?