A dsoxlab course is a git repository with a meta.yml at the root and one
lab.yaml per lab under labs/. The engine asks for nothing else: no
plugin to write. This lesson follows the creation of a catalogue from end to
end: the skeleton laid down by dsoxlab new, the mission and its scoring,
the hints and their cost, the tests that prove success, then the validator
that refuses a lab before a learner has to put up with it. You finish with a
shell lab that validate-structure accepts and that dsoxlab check scores
at 100.
Prerequisites: dsoxlab installed and up to date (Installing dsoxlab locally with uv or pipx), a first lab already played (Playing your first dsoxlab lab with dsoxlab demo), and enough to read a YAML file and a Python function of a few lines.
What you will learn
- Start from a demonstrable capability, never from a chapter to cover.
- Lay down a conforming catalogue and lab with
dsoxlab new. - Declare the contract in
meta.ymlandlab.yaml, and know what each one imposes. - Write the course, the situation, the graded mission and the hints that cost points.
- Prove success through pytest tests on the state of the system.
- Validate with
validate-structure, in the editor and in CI. - Publish the catalogue, then open evidence sending with
learning.sync, or leave it closed.
Start from a capability, never from a guide
A lab exists to have someone demonstrate a capability, that is, an
observable result on a system: create a user with key-only SSH access, extend a
logical volume and check that the mount survives a reboot, fix an SELinux
denial without disabling SELinux. One lab per chapter would make no sense:
nobody brings up a virtual machine to learn cut. If the capability cannot be
phrased with a verb and a verifiable result, the lab is not ready to be
written.
The runtime is the environment the lab runs in, and the subject dictates
it. vm means a dedicated virtual machine, shell a plain working directory
on the learner's workstation. Anything that touches sshd, systemd, a
firewall, SELinux, the boot or persistent storage is proved in a virtual
machine, because a container has neither a real boot cycle nor an SELinux
policy of its own. Anything that touches files, text, permissions or a tool
that runs on the workstation, such as Terraform, is played in shell and
costs almost nothing.
The tests never check that a command was typed: the learner can type the right
command and miss the goal. They check the state of the system and, as soon
as the subject warrants it, persistence after a reboot: a firewall rule
added without --permanent, a mount absent from /etc/fstab, a service
started but not enabled with enable. A test on the state catches these
oversights, a test on the command history lets them through.
The structure of a catalogue
A catalogue is an ordinary repository. Its labs stay readable and playable
without the engine: a shell lab is replayed with a plain pytest, and the
playbooks of a vm lab are run by hand with ansible-playbook setup.yaml.
That constraint keeps the engine independent of the subject of the labs,
because it reads a contract and imposes no content. One point depends on
dsoxlab: to reach a machine, the tests of a vm lab call lab_host(), a
function of the conftest.py that imports dsoxlab modules (see "Tests that
prove"). Here is what a catalogue carries, with one complete lab:
ma-formation/├── meta.yml # catalogue: identity, topology, section order├── meta.fr.yml # optional: French titles and descriptions├── conftest.py # written by dsoxlab new catalog: message(), workdir_lab(), exiger_workdir(), lab_host(), host fixture├── ssh/id_ed25519.pub # public key, produced by instructor bootstrap (vm labs)└── labs/ └── premier-lab/ ├── lab.yaml # required ├── lab.fr.yaml # optional: title and description in French ├── README.md # required: the course ├── README.fr.md # optional: the course in French ├── setup.yaml # required for runtime vm (Ansible) ├── cleanup.yaml # required for runtime vm (Ansible) ├── fixtures/ # optional, for runtime shell └── challenge/ ├── README.md # the situation and mission shown by dsoxlab challenge ├── README.fr.md # optional: the same, in French ├── hints.yaml # optional: the hints and their cost └── tests/ └── test_functional.py # required, exact nameThe validator requires challenge/tests/test_functional.py, with that exact
name, and challenge/README.md: without the latter, it reports "Missing file:
README.md". The .fr files stay optional. The tree under labs/ is free: a
lab is discovered by its lab.yaml, wherever it sits, and dsoxlab new lab
puts its own directly in labs/<id>/.
Zero bash is enforced: preparing a lab is declarative, in lab.yaml for a
shell lab, or Ansible, in setup.yaml for a vm lab. The validator
therefore refuses scripts depending on the runtime: cleanup.sh and
runtime/shell.sh in a shell lab, runtime/kvm.sh in a vm lab, and
Makefile in both.
Laying down the skeleton with dsoxlab new
Two commands create files that are conforming without any touch-up, which
avoids the fields forgotten in a lab.yaml written from memory. new catalog writes 33 files: meta.yml and meta.fr.yml, a conftest.py, a
pyproject.toml, the README in both languages, the governance documents
(licence, security, contributing, code of conduct), the CI and release
workflows, its own tests, and it creates the labs/ and ssh/ directories.
new lab lays down a lab, registers it in the first section of the
meta.yml and makes it visible to the next list-labs.
dsoxlab new catalog ma-formation --in ~/Projets # the cataloguecd ~/Projets/ma-formationdsoxlab new lab premier-lab --runtime shell # the lab of this lessondsoxlab new lab lab-vm --runtime vm # a second one, to comparedsoxlab list-labs # both are already discoveredWithout the --github <owner> option, new catalog leaves the <owner>
placeholder in the README badges and in RELEASING: replace it with the GitHub
account or organisation that hosts the catalogue. The command also offers to
run uv lock, the dependency lockfile that the commit hook checks. The
LICENSE file carries the CC BY 4.0 licence; replace it if your catalogue uses
another one.
new lab writes lab.yaml, lab.fr.yaml, README.md, README.fr.md,
challenge/README.md, challenge/README.fr.md and
challenge/tests/test_functional.py, plus setup.yaml and cleanup.yaml for
a vm runtime. Here is the output for the shell lab, then the one from
list-labs (path shortened, a second lab lab-vm created with
--runtime vm):
✔ Lab 'premier-lab' created in …/ma-formation/labs/premier-lab (shell)ℹ Added to section 'premiers-pas' of meta.yml. That position is theteaching order, which 'dsoxlab next' follows.ℹ It already matches the contract, and its tests fail until they are written: dsoxlab list-labs dsoxlab validate-structureThen fill challenge/README.md, and challenge/tests/test_functional.py. Available labs┏━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━┓┃ ID ┃ Title ┃ Level ┃ Runtime ┃ Score ┃┡━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━┩│ premier-lab │ To fill in │ l1 │ shell │ · │├─────────────┼────────────┼───────┼─────────┼───────┤│ lab-vm │ To fill in │ l1 │ vm │ · │└─────────────┴────────────┴───────┴─────────┴───────┘ℹ 3 of 8 columns are hidden, for lack of width: dsoxlab list-labs --long showsthem all.Both labs show up with the title "To fill in". That title comes from the
lab.yaml that new lab writes, because this session is in English: a session
in French would read lab.fr.yaml and show "À remplir". The score · means no
result is recorded yet. The final message says where to write: the situation and the mission go in
challenge/README.md, then the tests. The generated test fails on purpose
until it is written, so that an empty lab never returns a success. The
sections that follow fill the lab in this order: lab.yaml, the mission, the
hints, the tests, then you play it.
The meta.yml: identity, topology, order
Only repo.id is required. repo.category is required by the
validator as soon as a lab.yaml exists, because it becomes the default
section of every lab, and a lab without a section would stay unreachable
through list-labs --section. The infra: block is only required by vm
labs: dsoxlab for the trainer: the infrastructure of vm
labs details it, and a catalogue
without it is conforming, not incomplete.
Here is the meta.yml that dsoxlab new catalog ma-formation writes, then
that new lab completes with the two labs of this lesson, as is, comments
included. The texts to fill in are in English, the tool's default language; the
comments, for their part, are in French:
# Catalogue ma-formation, décrit par le contrat v1 de dsoxlab.## `repo.id` sert de clé pour l'état local de ce catalogue : le changer# déplace ces emplacements.schema_version: 1
repo: id: ma-formation category: ma-formation title: ma-formation description: | To fill in: what this catalog teaches, and to whom.
# Où remettre une preuve d'apprentissage, si ce catalogue a un portail. En# `https` : le lien porte les résultats d'un apprenant. dsoxlab n'envoie rien :# il affiche une adresse, et l'apprenant décide.## learning:# portal_url: https://formation.example.org/mon-apprentissage/
# Un catalogue sans lab `vm` n'a pas besoin de bloc `infra:`. Décommente-le le# jour où un lab déclare `runtime.type: vm`.## infra:# provider: kvm# network: ma-formation-net# cidr: 10.10.10.0/24# hosts:# - name: hote.lab# distro: alma10
sections: - id: premiers-pas title: First steps description: To fill in. labs: - premier-lab - lab-vmThe catalogue is ready to play without changing anything, and every passage to
write is marked "To fill in". Two rules of the contract surprise people on first
reading. Discovery goes by path, never by id: a lab exists if and only if
labs/**/lab.yaml exists, and sections[].labs[] only orders the labs and
names the blocks, by comparing the path relative to labs/. That is why new lab premier-lab simply registers premier-lab in the section.
The second rule concerns issues_url, absent from the template: add it under
repo, because that is where dsoxlab support --issue files a learner's
report, instead of guessing the origin remote.
The meta.yml carries English, the tool's default language: replace
"First steps" and "To fill in" with your own English texts. French lives in
meta.fr.yml, placed next to it, which new catalog writes with "Premiers
pas" and "À remplir" for you to replace in turn. That file overrides repo.title,
repo.description and the titles and descriptions of sections, matched by
id and never by position, and nothing else: the teaching order is not
translated.
The lab.yaml: what the parser requires, what the validator requires
Three fields are required by the parser, id, title and level:
without them, the file is not a lab, and it disappears from the catalogue.
Three others are required by validate-structure, skills, distros and
doc_url: the file reads without them, but the lab is not publishable.
doc_url is the only link between the lab and the online guide, the one
dsoxlab guide opens: it must be http(s) and point to a real page.
level is a free-text level label: l1 is the value new lab writes (the
most accessible level), and the validator only checks that it is not empty.
new lab writes these fields with template values (title: "To fill in",
skills: [a-remplir], doc_url: https://example.org/a-remplir), and adds
comments in French, among them those that explain feedback and status. The
validator accepts the template values as they are; they are marks to replace.
Write title and description in English in lab.yaml, and put the French
version in lab.fr.yaml, which new lab writes with "À remplir". Here is the
lab.yaml of this lesson's shell lab once filled in, without the comments
new lab adds to it:
# yaml-language-server: $schema=https://raw.githubusercontent.com/stephrobert/dsoxlab/main/schemas/lab.schema.jsonid: premier-labtitle: "Create a report file"level: l1description: "Create a text file."skills: - fichiersdistros: - anydoc_url: https://www.stephane-robert.info/docs/dsoxlab/lab_type: labestimated_time: 30mruntime: type: shell workdir: challenge/work fixtures: []validation: functional: trueThe lab.fr.yaml next to it carries only title and description, any other
field in it is silently ignored:
title: "Créer un fichier de rapport"description: "Créer un fichier texte."Fill in the lab's README.md too, along with its README.fr.md. A shell
lab works in a workdir, challenge/work by default. Its fixtures list
names the files of fixtures/ that run copies into that directory, for
example fixtures: [donnees.txt]. It can also declare services,
containers the lab needs for the duration of the exercise. The validation
block is purely declarative: dsoxlab never reads it to decide, the tests
are what proves.
A vm lab replaces workdir and fixtures with targets, the machines the
tests inspect:
runtime: type: vm # shell or vm; never kvm nor incus in a new lab targets: - name: rhel host: alma-rhcsa-1.lab # checked against infra.hosts[].name if the meta.yml declares any label_fr: "AlmaLinux 10" default: rhel snapshot_required: falselab_type accepts four values, and the fourth is not an exercise. lab,
challenge and capstone (the final project of a level) assume a learner who
does the work. They differ in scope, and also in what dsoxlab check shows of
a failed test: a lab prints the author's whole message, a challenge its
first line, a capstone no message. A lab that carries an exam_passing_score
behaves like a capstone on that point. The feedback field (full,
first-line or verdict) changes that default, and Getting your work checked
with dsoxlab check and submit
shows the result on the learner's side.
validation is a suite of assertions that defends a published guide: a red
test there points at a page to refresh, not at a learner at fault. So nothing
is graded there, next never suggests it, validate-structure requires no
scoring, and its attempts never leave towards an account. A lab_type: challenge or capstone with an exam_passing_score between 1 and 100 becomes
a mock exam, and submit renders a verdict as a percentage of the scoring:
those are the only two forms where a pass mark means anything, and the
validator reports a score placed on any other.
A lab that is not ready yet is pushed with status: draft: it stays in the
repository, but list-labs, next, progress, export and push ignore it.
The course, the situation, the mission and its scoring
Two Markdown files, and the engine reads each at a different moment.
README.md is the course: what the lab teaches, and what it assumes
known; dsoxlab course prints it, then ends with "Challenge ready: dsoxlab
challenge premier-lab", the command to run next. challenge/README.md
carries the situation and the mission. The situation says where the learner is
and what is wrong, without the steps that fix it; the mission says what they
must obtain. This file is printed by dsoxlab challenge, and by run before
the SSH session of a vm lab opens, since the host has no dsoxlab. A
scenario.md file is forbidden: validate-structure fails if it exists.
new lab writes each of these two files in English (README.md) and in
French (README.fr.md). The templates carry "TO FILL IN" in the English files
and "À remplir" in the French ones. Fill in both
languages: challenge/README.fr.md is read first when it exists, so a French
template left as is will be the one the validator and a French-speaking
learner see. Here is the challenge/README.md of this lesson's lab:
# Challenge: create a report file
## The situation
The working directory is empty. The team is waiting for a report file.
## What you must get
2 tasks, 100 points, 5 minutes
### Task 1: the file exists (50 pts)
A file `rapport.txt` exists in the working directory.
### Task 2: the file is not empty (50 pts)
The file contains at least one line.challenge/README.fr.md, the French statement, is filled in the same way, with
the same tasks and the same points. The scoring check described below reads
README.fr.md when it exists, and never looks at the English statement. A
scoring mistake in README.md therefore goes unnoticed: proofread it yourself.
The mission carries the scoring, and the validator keeps it in step with
the tests. dsoxlab grades per test: five test_ functions in
test_functional.py make twenty points each, the cost of the hints being
deducted from the scale before that calculation. A ### heading carrying (N pts) or (N points) is a graded task, a line announcing N tasks and M
points is the announcement, and ## headings are not counted, which lets a
mock exam group its tasks without doubling its total. Here, two tasks of 50
points match the two tests written further down.
If you write the mission before the tests, the gap shows right away: the generated test file contains a single test, and the mission announces two.
Content: ✘ premier-lab · labs/premier-lab/challenge/README.fr.md: 2 scored task(s) for 1 test(s): the score is computed per test, so the scale on display is not the mark that comes out✘ 1 lab(s) out of 2 have structure or metadata issues.The message names the file to fix and says why: the mark comes from the tests,
never from the points written in the mission. The command exits with code 1.
Once the second test is written, the validator answers ✔ All labs are valid.
The announcement is only read if it carries "tasks" or "tâches" in the plural,
followed by the total in points or pts: "1 task, 80 points" is not
checked. The three scoring anomalies each carry their own key:
content_scoring_tasks_vs_tests, content_scoring_points_mismatch for the
total and content_scoring_count_mismatch for the announced count.
validate-structure fails when the tasks do not add up to the announced
scoring, when their count differs from the announced one, or from the number
of tests. Adding a test to a lab silently reweights its whole scoring, and
this check is the only thing that notices. A mission that announces no points
per task is not checked at all: a mock exam that verifies several things per
task made another choice, just as valid.
Your turn
Add a donnees.txt file (containing three lines, a, b and c) to the lab,
then a third task: the first line of rapport.txt must be the number of lines
of donnees.txt. The scale stays at 100 points. What does validate-structure
answer before you write the test, and how many points is each task worth?
A hint
The file to copy into the working directory is declared in lab.yaml. One
hundred points do not split into three equal parts.
I have tried: show the answer
Put the file in fixtures/donnees.txt and declare it in lab.yaml with
fixtures: [donnees.txt]: a fixture that is not declared is never copied. In
challenge/README.md and challenge/README.fr.md, announce 3 tasks, 100 points (in French, 3 tâches, 100 points), set the first two tasks to 33
points and add a task 3 at 34 points. As long as the test does not exist, the
validator refuses:
Content: ✘ premier-lab · labs/premier-lab/challenge/README.fr.md: 3 scored task(s) for 2 test(s): the score is computed per test, so the scale on display is not the mark that comes out✘ 1 lab(s) out of 2 have structure or metadata issues.Add this test to test_functional.py, then run validate-structure again: it
answers ✔ All labs are valid.
def test_compte_les_lignes() -> None: exiger_workdir(WORK, "premier-lab") rapport, donnees = WORK / "rapport.txt", WORK / "donnees.txt" attendu = str(len(donnees.read_text().splitlines())) assert rapport.is_file() and rapport.read_text().splitlines()[:1] == [attendu], message( en="The first line is not the line count.", fr="La première ligne n'est pas le nombre de lignes.", )In the session opened by dsoxlab run premier-lab, wc -l < donnees.txt > rapport.txt writes the right number, and dsoxlab check premier-lab prints
100 / 100 pts with 3/3 tests. If the first line of rapport.txt is wrong
(premier rapport, for example), check prints 67 / 100 pts with 2/3 tests: each test is worth a third of 100, rounded, and the message "The first
line is not the line count." appears under "What is left to do". The 33, 33 and
34 split stays a display choice: the validator checks the total and the number
of tasks, not the distribution.
The hints, and their cost
challenge/hints.yaml carries the lab's scale and the hints, in the order
they will be handed out. A good hint directs the eye, "what does
journalctl -u <service> say?", and never gives the final command. The cost of
each one is deducted from the scale, and it is worth 10 points when it is
not written. The points field sets that scale, and is 100 when the file is
absent.
points: 100 # the lab's scalehints: - text_en: "The group must exist before the user does." text_fr: "Le groupe doit exister avant l'utilisateur." cost: 10 # points removed when the learner takes it (default 10)For this lesson's lab, a single hint is enough:
hints: - text_en: "echo can write a file with >." text_fr: "La commande echo peut écrire dans un fichier avec >." cost: 10The learner takes the next hint with dsoxlab hint premier-lab. The command
prints the text, the cost of the hint and the total already deducted:
╭─────────────────── Hint ────────────────────╮│ 💡 Hint 1/1 ││ ││ echo can write a file with >. ││ ││ Cost: -10 pts Total hint penalty: -10 pts │╰─────────────────────────────────────────────╯The cost is deducted from the scale before the proportion of passed tests
is computed, not from the final mark. With a hint at 10 points, the scale falls
to 90. If rapport.txt exists but stays empty, one test out of two passes and
the mark is half of 90:
╭─────── Result: premier-lab ───────╮│ 45 / 100 pts ││ ██████████░░░░░░░░░░ 1/2 tests ││ 1 hint used, -10 pts │╰───────────────────────────────────╯Once rapport.txt is filled in, both tests pass and the mark is 90 / 100 pts, not 100: taking a hint sets a ceiling of 90 until the lab's dsoxlab reset, which puts the hints back to zero.
A single legacy text key is still read, and a base64 value is decoded so
that a hint does not surface in a git grep; neither is needed in a new
lab. The site's catalogues encode their hints, and that is not encryption:
only enough to prevent a hint from being read by accident when opening the
file.
Tests that prove
A lab is graded by pytest with pytest-testinfra, both bundled in
dsoxlab: a catalogue installs no test tooling. pytest runs from the catalogue
root, so a conftest.py placed there is collected for every lab. The file
generated by dsoxlab new catalog provides four functions and a fixture there:
message(en=…, fr=…), which writes the text of a failure in the learner's
language, workdir_lab(__file__), which resolves <lab>/challenge/work from
the location of the test, exiger_workdir, which skips the test instead of
scoring it 0 when dsoxlab run has not been played, lab_host(fqdn), which
opens a testinfra connection to a machine of the catalogue, and the host
fixture, which the tests receive as an argument. Only lab_host imports
dsoxlab modules, and it does so in its body: a shell lab is therefore
replayed with a plain pytest, without the tool.
The assertions bear on the state: the service runs, the port listens, the
mount is present, the file has the right permissions. For a shell lab, the
test reads the working directory with the functions of the generated
conftest.py. Here is the challenge/tests/test_functional.py of this
lesson's lab, one function per task of the mission:
# challenge/tests/test_functional.py of a shell labfrom conftest import exiger_workdir, message, workdir_lab
WORK = workdir_lab(__file__)
def test_fichier_present() -> None: exiger_workdir(WORK, "premier-lab") assert (WORK / "rapport.txt").is_file(), message( en="rapport.txt is missing.", fr="rapport.txt est absent." )
def test_fichier_non_vide() -> None: exiger_workdir(WORK, "premier-lab") fichier = WORK / "rapport.txt" assert fichier.is_file() and fichier.read_text().strip(), message( en="rapport.txt is empty.", fr="rapport.txt est vide." )To get these results yourself, open the session with dsoxlab run premier-lab, run dsoxlab check premier-lab before any work, create the file
with echo "premier rapport" > rapport.txt (the session opens in
challenge/work), then run check again. Here is the first output, before the
learner's work. Look at the total, 0 / 100 pts, then at the "What is left to
do" list:
ℹ Validating premier-lab… ✘ test_functional.py::test_fichier_present (FAILED) ✘ test_functional.py::test_fichier_non_vide (FAILED) Tests premier-lab finished ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00What is left to do, according to the tests: ✘ fichier present rapport.txt is missing. ✘ fichier non vide rapport.txt is empty.ℹ The full test output: dsoxlab -v check premier-lab╭─────── Result: premier-lab ───────╮│ 0 / 100 pts ││ ░░░░░░░░░░░░░░░░░░░░ 0/2 tests │╰───────────────────────────────────╯ℹ Result saved to history (0/100 pts).✘ Some tests failed.This list reuses the messages of message(), in the learner's language: it is
the only instruction they get at the moment of failure. The title of each line
comes from the name of the test function. After rapport.txt is created, the
second output gives the full mark, each test being worth 50 points because the
lab has two:
ℹ Validating premier-lab… ✔ test_functional.py::test_fichier_present ✔ test_functional.py::test_fichier_non_vide Tests premier-lab finished ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/2 0:00:00╭─────── Result: premier-lab ───────╮│ 100 / 100 pts ││ ████████████████████ 2/2 tests │╰───────────────────────────────────╯ℹ Result saved to history (100/100 pts).✔ All tests passed.ℹ Score saved. Run dsoxlab submit to record your final attempt and end the session.A vm lab proves the state of a machine with testinfra assertions
(host.service(...), host.file(...)). The host fixture of the generated
conftest.py chooses the machine to inspect. In a shell lab, it returns the
learner's workstation. In a vm lab, it reads the
DSOXLAB_TARGET_HOST variable, which dsoxlab check --target sets;
without it, a pytest run on its own takes the default target of the
lab.yaml (runtime.default, then its host in runtime.targets). It then
passes that host to lab_host, which connects over SSH with sudo. If the host
is not in the inventory, lab_host stops with a message asking you to play
dsoxlab provision. If the lab declares no target, the fixture fails the test
and asks you to add runtime.targets to the lab.yaml.
Here is a one-assertion vm test, to adapt to your lab. The name of the
service (sshd here) depends on the distribution of the machine:
# challenge/tests/test_functional.py of a vm labfrom conftest import message
def test_sshd_actif(host) -> None: service = host.service("sshd") assert service.is_running and service.is_enabled, message( en="sshd must be running and enabled.", fr="sshd doit être démarré et activé.", )is_enabled checks that the service also starts after a reboot, which is the
persistence the start of this lesson talks about.
A catalogue created before this file was added receives neither lab_host nor
the host fixture: copy them from the conftest.py of a new catalogue. On the
playbook side, three Ansible groups are injected at run time: labenv,
every host of the meta.yml, lab_target, the resolved target that a lab's
playbooks must address, and one lab_<role> per entry of roles.
dsoxlab for the trainer: the infrastructure of vm
labs explains how machines are
declared, created and reachable over SSH.
Validating with validate-structure
dsoxlab validate-structure checks every lab of the catalogue, offline by
default, and exits 1 as soon as one lab fails. It plays three families of
checks, and names every anomaly by a stable key: that is what a script
filters, counts and compares on. It also reports the labs the engine cannot
see, which is the most confusing case: a lab.yaml present on disk but
unreadable, broken YAML or a required field missing, with the line to look at,
and a lab declared in sections[].labs[] with no lab.yaml at that location.
| Family | What is checked |
|---|---|
| Structure | lab.yaml, README.md, challenge/README.md, challenge/tests/test_functional.py; for vm, setup.yaml, cleanup.yaml, non-empty targets and a consistent default; for shell, a non-empty workdir; no forbidden file, scenario.md included |
| Metadata | id, title, level and doc_url non-empty, skills and distros non-empty, doc_url in http(s), lab_type within the closed list of values (lab, challenge, capstone, validation), exam_passing_score between 1 and 100 |
| Content | Every relative link of a Markdown file points to an existing file; the announced scoring matches the tests (read in challenge/README.fr.md when it exists, otherwise in README.md); a .fr.md without its English .md is reported; the hosts of targets and roles exist in infra.hosts, but only when the meta.yml declares infra.hosts; no file of solution/ is readable in clear text; fixtures/ and runtime.fixtures say the same thing |
On a new lab, the validator answers this, with return code 0:
✔ All labs are valid.When you add a scenario.md to the lab, the return code becomes 1 and the
message names the file and says where to write instead:
Lab structure: ✘ premier-lab · labs/premier-lab/scenario.md: scenario.md is no longer part of a lab: the situation and the mission both go in challenge/README.md (and README.fr.md).✘ 1 lab(s) out of 2 have structure or metadata issues.The "1 lab out of 2" here counts the lab-vm lab created earlier. Each line
names the lab, the file at fault and the expected fix. A solution/ readable
in clear text is refused the same way: the message asks you to encrypt it with
ansible-vault encrypt, otherwise git keeps the answer key forever.
--check-urls adds the only network check, every doc_url must answer,
and --json renders every anomaly with its key, its lab and its path. The
fixtures check is worth understanding: the shell runtime iterates over
runtime.fixtures, not over the fixtures/ directory. A fixture declared but
absent (fixtures: [b.txt] without fixtures/b.txt) makes run fail with
code 2 naming every offender at once, before the slightest copy; a fixture
present but undeclared is reported here, because it would never be copied and
the working directory would stay empty.
Splitting the course and translating
Without course.yaml, dsoxlab course prints README.md in one block,
which explains the length of long courses. The --next, --prev and
--section options already work, though: dsoxlab then splits the README.md
on its headings. For the following README.fr.md, three sections come out:
# Cours
Intro.
## Créer un fichier
Texte A.
## Vérifier
Texte B.dsoxlab course premier-lab --next first prints "Intro." (section 1/3), then,
on the second call, "Créer un fichier" (section 2/3) with the --prev and
--next links to its neighbours. --section 2 goes straight to that second
section, by its number or by its id, and the position is remembered so the
learner resumes where they stopped.
A course.yaml next to the lab.yaml replaces that automatic split with
your own: one section per file, with its title.
sections: - id: navigation title: Moving around the tree file: course/01-navigation.md - id: permissions title: Reading and changing permissions file: course/02-permissions.mdWith a course.yaml, --next, --prev and --section read these files, and
after the last section the command announces "You have read all 2 sections."
and points to dsoxlab challenge premier-lab. But dsoxlab course premier-lab alone always prints the whole README.md, never the files of
course/: the content of README.md and that of course/ do not replace each
other, and an author who moves their course into course/ must remember the
README.md that stays displayed.
Translations follow a single convention, per file: lab.fr.yaml
overrides the lab's title and description, meta.fr.yml the titles of
the catalogue and its sections, course.fr.yaml the section titles of the
course. A language suffix per field, such as title_en:, is not part of the
contract, is read by nobody, and validate-structure reports it.
The schemas, in the editor and in CI
Two JSON Schemas describe the same contract, schemas/meta.schema.json and
schemas/lab.schema.json. The files new writes carry no schema line: add as
the first line of the meta.yml or the lab.yaml the comment # yaml-language-server: $schema=<schema URL> (the URLs of both schemas are in
the stephrobert/dsoxlab repository, under schemas/, as in the lab.yaml
example above). Any editor running that server can then complete the fields and
underline skils: as you write it. Replace main with a version tag in
the URL to freeze the schema: main follows the contract as it evolves, a tag
never moves under your feet.
In CI, the ci.yml workflow that new catalog writes installs dsoxlab and
already runs validate-structure: a new catalogue has nothing to add for the
validation to run on every push. Unknown keys are ignored by the parser,
refused by the schemas and reported by validate-structure. The engine thus
stays tolerant, so that an older tool survives a newer catalogue, while the
editor and the validator let nothing through.
Playing your lab before publishing it
A lab never played is not a lab. Before any publication, the sequence is
the learner's, plus a return to zero to prove reproducibility:
validate-structure, then run, solve, check, then reset and replay. The
answer key, if one exists under solution/, must stay unreadable in clear
text, and the validator checks it.
dsoxlab validate-structuredsoxlab run premier-lab # opens a session in challenge/work; exit to leave itdsoxlab check premier-lab # the announced scale must be reacheddsoxlab reset premier-lab # asks for confirmation; then replay from scratchIn a session opened by run, exit leaves without recording anything;
check grades the work and records the score. Outside an interactive
terminal, reset refuses to run without --yes, which a test script must
allow for. The learner, for their part, finishes with dsoxlab submit, which
reruns the tests, records the score, then waits for exit to close the
session.
What remains is to wire the lab to its guide, in both directions: the
lab's doc_url points to the page that teaches the capability, and that
page announces the lab with its exact identifier, the one in the lab.yaml. A
lab nobody sees is played by nobody.
Publishing the catalogue and installing it like a learner
dsoxlab new catalog does not create a git repository, and catalog add
clones: you therefore need a repository with at least one commit. Create it in
the catalogue directory, then install it the way a learner would. A file://
URL is enough to try it, without publishing:
git init -b maingit add .git commit -m "First lab"dsoxlab catalog add file://$PWDThe command clones the repository under ~/.local/share/dsoxlab/catalogs/,
makes it active and prints Catalogue 'ma-formation' installed in <path>, and made active. dsoxlab catalog list then shows it under "Installed
catalogues", with a tick on the active ones, and dsoxlab list-labs works from
any directory. To publish it, push the repository to GitHub and give its URL to
catalog add. Installing and managing your dsoxlab lab
catalogues details installation, update and
removal.
Declaring the evidence portal: learning.sync
A catalogue that wants its learners to send their results from the
terminal declares a learning.sync block in its meta.yml. That declaration,
and it alone, makes dsoxlab login and dsoxlab push usable on the
catalogue: a catalogue that declares nothing sends nothing, and works with
no network call tied to progress at all. The learning block also accepts
portal_url, a plain link that the learner reads and decides to open;
sync is the sub-block that describes the API.
On the learner's side, this block turns into three commands, dsoxlab login, dsoxlab push and dsoxlab logout, described in The main dsoxlab
commands, in the order you use them. A meta.yml
that declares learning.sync also stays readable by an older version of the
CLI: the parser ignores unknown keys, and the catalogue goes on being played
without any sending. validate-structure checks the names of the keys of
learning and learning.sync, never their values: a wrong address is only
discovered at the first sign-in.
The fields that describe the portal are never secrets. They are public addresses and the identifier of a public OAuth client, that is, a client that holds no password. That client relies on PKCE (Proof Key for Code Exchange): the CLI proves it is the one that started the exchange, without a shared secret. The full flow is described in OAuth 2.x: delegating access to APIs (in French). This block can therefore live in a versioned repository without exposing anything.
| Field | What it names |
|---|---|
protocol | The synchronisation protocol the portal expects |
api | The address of the API that holds the account's evidence |
issuer | The identifier of the portal: it names the learner's local session, the CLI does not verify it |
oauth_domain | The sign-in domain where the learner authenticates |
client_id | The identifier of the public client the CLI uses |
callback_url or callback_port | The return address of the authorization, one or the other, and never both |
The values are taken from the portal you target, they are not invented. api,
issuer, oauth_domain and callback_url are written with https://,
otherwise the CLI refuses them. callback_port is a port number, and the
portal must have registered the same return address, identically, on the
side of its OAuth client. The skeleton looks like this, the values in angle
brackets being the ones the portal publishes:
learning: sync: protocol: learner-sync/1 api: "‹https://… : address of the evidence API›" issuer: "‹https://… : identifier of the portal›" oauth_domain: "‹https://… : sign-in domain›" client_id: "‹public client identifier›" callback_port: 14123The protocol field is learner-sync/1: any other name is refused by
dsoxlab login, which answers that this version does not speak it.
The two forms of return address are exclusive. dsoxlab login refuses a
catalogue that declares both, or neither, naming learning.sync.callback_url
and learning.sync.callback_port; validate-structure does not check these
values. The choice comes down to comfort and to what the portal really
accepts:
callback_portmakes the CLI listen on a loopback address and hand control back on its own as soon as the authorization returns. That is the most pleasant form for the learner;callback_urlnames a page of the portal that displays a code to copy back. It is slower, and sometimes the only route open.
Some providers refuse a return over http, even to the loopback address: test
a complete sign-in before publishing the catalogue.
Troubleshooting
These five cases are the ones that come up most often with a first catalogue. None is an engine failure: each comes from a gap between what you thought you declared and what the contract reads.
| Symptom | Cause | Solution |
|---|---|---|
The lab does not show up in list-labs | Its lab.yaml does not load: broken YAML, or id, title, level missing | dsoxlab validate-structure names it with the line and column; list-labs also prints a WARNING with the YAML error; the full detail is in ~/.local/state/dsoxlab/dsoxlab.log |
Missing file: README.md or Missing file: test_functional.py | challenge/README.md or challenge/tests/test_functional.py does not exist, the displayed path says which | Create the file at the given path, with that exact name |
content_scoring_tasks_vs_tests | The number of graded tasks in the mission differs from the number of test_ functions | Align the mission with the tests, or the reverse, then run the validator again |
run exits 2 and names a fixture | An entry of runtime.fixtures has no file under fixtures/ | Add the file, or remove the declaration; it is all or nothing before the slightest copy |
validate-structure fails on a lab that comes from an old model | The lab contains a scenario.md, a forbidden file | Move the situation into challenge/README.md, then delete scenario.md |
Key points
- A catalogue is a repository with a
meta.ymland onelab.yamlper lab; ashelllab is replayed with a plainpytest, without dsoxlab. - You start from an observable capability, the runtime is imposed by the subject, and the tests prove the state of the system.
dsoxlab new labwrites its files in two languages: English inmeta.ymlandlab.yaml, French in the.frfiles. Fill in both, the French is read first in a French session.- Discovery goes by path,
sections[].labs[]only orders;runtime.typeisvm, andruntime.hostdoes not exist. - The mission announces a scoring per task, one task per test, and
validate-structurerefuses any gap between the two. - A hint costs 10 points by default, deducted from the scale before the proportion of passed tests, and directs the eye without giving the command.
conftest.pylives at the catalogue root; for avmlab, itshostfixture opens the connection to the machine named byDSOXLAB_TARGET_HOST, or to thelab.yamldefault target.- A lab never played is not a lab:
validate-structure,run,check,reset, then replay. learning.syncopens evidence sending, withcallback_urlorcallback_portbut never both; without that block, the catalogue sends nothing.