Suil modules declaration
A workspace declares the modules it uses in one file, modules.yaml, the way
pre-commit declares its hook repositories in
.pre-commit-config.yaml. suil installs the modules from there over plain
HTTP; it never runs Git. A module carries no manifest of its own: its version
is the one modules.yaml pins it to.
Today
- A module is any directory under
modules/. What it is follows from which files happen to exist: nocode/main.pymakes it a meta module. - Dependencies live in
requires.yaml, one list, and nothing else about the module is declared. - Modules have no version, and the only way to use a module is to have it in the same repository as the data.
- A missing function, a wrong signature or a typo in a file name shows up only when a run reaches that module.
modules.yaml
modules.yaml sits in the workspace root, beside data/:
repos:
- repo: https://modules.example.com/suil
modules:
hostname: 0.1.0
ssh: 0.3.1
- repo: local
modules: [docker, nginx, unbound]
repo- thehttp(s)://URL of a source, orlocalfor modules written in the workspace itself.modules- for a source, a map of module name to version, so every module is pinned on its own; forlocal, a list of the directories undermodules/.
A module is named by its directory name, and a name must be unique across
modules.yaml. Roles and nodes keep selecting modules by that name.
Every module lives in modules/<name> of the workspace, wherever it came
from. A source is only where suil install takes it from, and nothing
after the install knows about it. Whether installed modules are
committed or ignored by Git is the workspace's choice.
Sources
A source is any static HTTP server: nginx, an object store, anything that
serves files. Under its URL it serves index.yaml and one archive per module
version:
modules:
hostname:
- version: 0.1.1
url: hostname-0.1.1.tar.gz
sha256: 9f2c...
- version: 0.1.0
url: hostname-0.1.0.tar.gz
sha256: 41ab...
url- the archive, relative to the source URL or absolute.- An archive
<name>-<version>.tar.gzholds<name>/and nothing else, never the repository the module is written in.
Module version
A module's version is the one modules.yaml pins it to, a semver version
released from a <module>-<version> tag. There is no module.yaml inside the
module and nothing in it to keep in step with the tag. The signature covers
the module's files alone, so a new version forces the module once on every
node only where its files changed.
Installation
suil install reads the index of every source, downloads the archive of each
module at its version, checks its sha256, and lays it into modules/,
replacing what is there. It does nothing for local. An archive whose digest
differs, or that holds anything besides its module, lays nothing.
A module whose .cz.yaml in modules/ already names its version is skipped
and reported as already installed, skipped; nothing is downloaded for it.
suil install --force lays every module again, edits made by hand included.
The index is read past any cache on the way, and suil autoupdate prints
when it was last modified, so an index served stale shows itself.
suil autoupdate moves every module of a source to the newest version in the
index, compared by semver, and rewrites modules.yaml line by line, so its
layout and comments stay; nothing else changes a version.
suil config, suil facts and suil apply never touch the network. They
read modules from modules/ only, and fail with the suil install command
to run when a declared module is not there.
Validation
suil validate checks the declaration and every module it names, and
connects to no node.
modules.yamlparses, every module of a source has a version, andlocallists its modules without one.- Every declared module is in
modules/, every directory there is declared, and no name is declared twice. - Every
requires.yamlentry names a declared module, and the graph has no cycle. - Every module with code implements the interfaces from 03-sdk.md, each method with its protocol's signature.
- A module with no code has a
requires.yamland nothing but it, itsREADME.md, itstests/and its release files.cz.yamlandCHANGELOG.md. - A module imports suil only through
suil.sdkandsuil.testing, in its code, its collector and its tests. - Nothing under a module's
code/reads the node:get_fact,run_commandandhost_run_commandbelong infacts/collector.py.
Each failure names the module, the file and what to change. suil config,
suil facts and suil apply run the same validation before they build the
catalogue.
Publishing
A module repository keeps its modules under modules/<name> and its
index.yaml at the root, committed. A module is released with cz bump in
its directory: the version comes from the version: of its .cz.yaml, and a
pre-bump hook records the release in index.yaml, so the bump commit and its
tag <name>-<version> carry the index. Publishing packs the tagged module
and uploads it with that index.yaml; the live source is never read back.
# modules/<name>/.cz.yaml
commitizen:
version: 0.1.0
tag_format: <name>-$version
pre_bump_hooks:
- cd ../.. && .venv/bin/suil index "$CZ_PRE_NEW_TAG_VERSION" && git add index.yaml
suil index hostname-0.1.1 # index.yaml: hostname 0.1.1 and its sha256
suil pack hostname-0.1.1 # dist/hostname-0.1.1.tar.gz and dist/index.yaml
Both run at the root of the module repository.
suil index TAG- the module is the directory undermodules/the tag starts with, followed by a semver version, songinx-extra-1.0.0is nevernginx; the version must be the one in its.cz.yaml. It packs the module and records it inindex.yamlas the module's only release.suil pack TAG- packs the same module intodist/and copiesindex.yamlbeside it. A releaseindex.yamldoes not hold, or a module whose bytes differ from what it records, is an error: the module changed after its bump. The archive has the same bytes on every build: sorted entries, mtime 0, owner 0, no__pycache__.
Uploading dist/ is the publisher's: suil names no host. The upload adds the
archive and replaces index.yaml, and the publisher removes the archives
index.yaml no longer lists, so a source serves the newest release only.
On any CI
Any CI, or a workstation, runs the same steps on a checkout of the module repository at the tag; the GitHub action below is these steps.
pip install droch-shuil # Python 3.11 or newer
suil pack "$TAG" # TAG is <module>-<version>
rsync -a dist/ "$UPLOAD_TARGET" # or any upload that reaches the source URL
GitHub Actions
droch-shuil ships the packing as the action publish. Its venv is cached in
the calling repository, so a release installs droch-shuil once per version.
The upload is the next step, with whatever action reaches the source; here
the source is a GitHub release:
on:
push:
tags: ["*-*"]
permissions:
contents: write
concurrency:
group: publish-modules
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- id: suil
uses: oberon-systems/droch-shuil/publish@v0.7.3
- uses: softprops/action-gh-release@v2
with:
tag_name: modules
files: ${{ steps.suil.outputs.dir }}/*
- env:
GH_TOKEN: ${{ github.token }}
run: |
listed=$(grep -oE '[^ ]+\.tar\.gz' index.yaml)
gh release view modules --json assets --jq '.assets[].name' | grep '\.tar\.gz$' |
while read -r name; do
grep -qxF "$name" <<<"$listed" || gh release delete-asset modules "$name" --yes
done
The action installs the droch-shuil of its own ref, so pin it to a tag, or
set suil-version.
GitLab CI
The steps above as a job:
publish:
image: python:3.12
resource_group: publish-modules
rules:
- if: $CI_COMMIT_TAG
script:
- pip install droch-shuil
- suil pack "$CI_COMMIT_TAG"
- rsync -a dist/ "$UPLOAD_TARGET"
Locally
The same steps by hand, from the root of the module repository checked out at the tag. The GitHub workflow itself runs on a workstation with act, given a tag push event:
act push --eventpath tag.json # {"ref": "refs/tags/hostname-0.1.1"}
Migration
The workspace gets a modules.yaml with one repo: local entry listing
every directory under modules/. Nothing moves and nothing is renamed, so the
resolved module order of every role stays the same. Moving modules into their
own repositories is a later step of the plan.
Acceptance
modules.yamldeclares every module undermodules/, and a directory it does not declare is an error.suil validatepasses on the tree and runs in CI through pre-commit.- Every role resolves the same module order and the same
.runs/catalogue as before the change. - A source serving archives built by
suil packandsuil indexinstalls intomodules/, and validates with the server gone, in tests against a local HTTP server.