- Shell 69%
- HCL 10.7%
- Makefile 9.1%
- Python 7.9%
- Jinja 2.1%
- Other 1.2%
|
All checks were successful
deploy / deploy (push) Successful in 2m41s
Reviewed-on: #70 Reviewed-by: Minos <noreply+minos@thepit.space> |
||
|---|---|---|
| .agents/skills | ||
| .forgejo/workflows | ||
| .mise/locks/pypi-ansible-core/2.21.5 | ||
| bao/recipients | ||
| container | ||
| docs | ||
| inventories/test | ||
| modules/guest | ||
| npm | ||
| scripts | ||
| test/guest | ||
| vikunja | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| env.map | ||
| GLOSSARY.md | ||
| LICENSE | ||
| Makefile | ||
| mise.lock | ||
| mise.toml | ||
| README.md | ||
| skills-lock.json | ||
infra-tracker
OpenTofu + Ansible that provision and maintain a self-hosted Tracker on the Pit homelab.
OpenTofu creates the Guest on the Proxmox Node, Ansible installs the Tracker on it natively, and NPM publishes it from the Edge — the same three-layer shape, in that order. The repo name and the folder layout are deliberately generic so the implementation can be swapped later; the folders themselves keep the current implementation's name because that is what runs today.
Requirements
- A Proxmox VE Node reachable from the machine that runs OpenTofu, and an API token for it.
- The repo's toolchain, installed once with
make deps. mise is the dependency manager:mise.tomldeclares the tools the targets call — OpenTofu, ansible-core and Python, withuvto resolve the Python ones, plusjq,ageandbaofor the fetch —mise.lockpins what those requests resolved to, and the Ansible collection comes fromvikunja/service/requirements.yml. - An account on the Edge (NPM) that may manage hosts, and the certificate for the domain already requested in the NPM UI.
Environment variables
No secret is committed in the clear, and since the cutover none is committed
encrypted either. The root .env is the one file a machine holds — .env.example
declares its names — and make env is what writes it, from the store
infra-silo runs and from the sealed Proxmox pair beside it, under a stamp line
naming the actor, the time and the store:
mise exec -- make env ACTOR=pit # make env serves the Operator, the Admin agent, the Semaphore runner and the CI login; a regular agent's call refuses, naming its class
scripts/env.sh is that fetch, vendored byte-for-byte from infra-secrets with
the sha it was vendored at on its second line, and env.map is this repo's only
input to it — one row per store path, a literal row for each name no path can
fill, and an actors= prefix on a row that only some actors' fetch reads. One
.env is one actor's: the map sources every name below for the Operator and the
Admin agent but the CI login's one and the runner's SSH key, the names a deploy
runs with (that key among them) for the Semaphore runner, and the one that starts
its task for the CI login. A literal
row is a declaration, not a source: the age class fills the PROXMOX_VE_* names
only where prod.age is present, and the fetch names each literal it could not
fill not held. infra-secrets' own
docs/env-fetch.md
is the interface once, for all five repos. make env-check compares the vendored
copy against its pin and the map against .env.example, reads no store, and sits
on the floor with make check.
| Variable | What it is |
|---|---|
PROXMOX_VE_ENDPOINT |
The Proxmox VE API endpoint the Guest stack talks to, from the sealed ~/.secrets/proxmox/prod.age |
PROXMOX_VE_API_TOKEN |
The API token that applies that Node, from the same file — never the store, because the token builds the Guest the store runs on |
VIKUNJA_DB_PASSWORD |
The database role's password, from secret/services/vikunja/prod/db |
VIKUNJA_SERVICE_SECRET |
The Service's token secret, from secret/services/vikunja/prod/app |
VIKUNJA_SMTP_USERNAME |
The mailer's username, from secret/services/vikunja/prod/smtp |
VIKUNJA_SMTP_PASSWORD |
The mailer's password, from the same record |
VIKUNJA_PIT_PASSWORD |
The pit account's password, from secret/services/vikunja/prod/accounts/pit; the role rebuilds its account map from it |
TEST_VAULT_PASSWORD |
The dev/ci Vault's password, from secret/ci/tracker/test-vault-password; make test derives the gitignored inventories/test/vault-pass from it, and CI holds the same value as a repo secret |
SEMAPHORE_API_TOKEN |
The tracker's Semaphore API token, from secret/ci/tracker/semaphore-api; the CI login is served this name and no other, and CP-39's deploy.yml starts the task with it |
NGINXPROXYMANAGER_URL |
The NPM API URL the Edge stack talks to; no store path holds it, so a deploy task gets it from Semaphore, as an environment variable on the tracker's project, which semaphore/projects in infra-cockpit sets from its own NGINXPROXYMANAGER_URL Actions Variable |
NGINXPROXYMANAGER_USERNAME |
The NPM account the Edge stack authenticates as, from secret/homelab/npm/tracker/manage |
NGINXPROXYMANAGER_PASSWORD |
That account's password, from the same record |
GUEST_STATE_AWS_ACCESS_KEY_ID |
The Guest Stack's key to its own object in the store, from secret/tofu-state/tracker-guest/apply; the Makefile exports it as AWS_ACCESS_KEY_ID before make guest-plan/guest |
GUEST_STATE_AWS_SECRET_ACCESS_KEY |
The secret half of that pair |
EDGE_STATE_AWS_ACCESS_KEY_ID |
The Edge Stack's key to its own object in the store, from secret/tofu-state/tracker-edge/apply; the Makefile exports it as AWS_ACCESS_KEY_ID before make edge-plan/edge |
EDGE_STATE_AWS_SECRET_ACCESS_KEY |
The secret half of that pair |
The state's two pairs are per Stack, not per repository: each production Stack
keeps its state as an object of its own in the store infra-silo runs, and the
S3 backend reads one pair out of the environment, so the Makefile hands each
Stack the pair that belongs to it. Each record holds the pair under two halves —
the apply half the Operator fetches, and the deploy half the Semaphore
runner fetches to deploy the Stack — and each pair has a read-only plan half
too — secret/tofu-state/tracker-{guest,edge}/plan — which a plan job reads as
a repository secret of its own, and which never enters a local .env
(docs/reference/state.md says where the state lives,
how a clone reads it and how it comes back).
Running
A merge to main deploys: deploy.yml starts this repository's deploy on
Semaphore, which runs it on its own runner
(the deploy). The commands below are the same Targets
by hand — the Operator's path, and an agent's when it works on this repository —
and a hand apply made while a Semaphore task is running is two applies at once,
so look at Semaphore's task list first.
Almost every step is a make target at the repo root. They are run through the
dependency manager — mise exec -- make <target>, which makes the declared tools
available to make and to everything make runs. Two one-time prerequisites sit
outside make: the base image is imported once before the first run, in
docs/reference/guest.md, and the machine's .env is fetched once — and again
whenever a value rotates — with make env ACTOR=<actor>, as
docs/reference/state.md sets out. A clone that has
never fetched still runs make check: it is the floor, and it reads nothing.
make deps # the one install step: the manager, the pinned tools, the collection
mise exec -- make help # list the targets (changes nothing)
# read-only — these change nothing on Prod
mise exec -- make guest-plan # the Guest stack plan
mise exec -- make service-check # the Service layer's --check --diff run
mise exec -- make edge-plan # the Edge stack plan
mise exec -- make verify # the external check, seen from the WAN
mise exec -- make fmt # format every OpenTofu file — rewrites an unformatted .tf
mise exec -- make validate # validate every stack
# mutating — each stops at the Apply gate, except the restore point a deploy takes first
mise exec -- make snapshot # predeploy-<UTC date>-<time> on the Guest; the three newest kept, the rest pruned by name
mise exec -- make guest # plan the Guest stack, render it, then create the Guest
mise exec -- make service # rehearse the install, then install the Service
mise exec -- make edge # plan the Edge stack, render it, then publish the Edge
mise exec -- make prod # the whole deploy, in order: snapshot, guest, service, edge, verify; stops at the first failure
make deps is the one target that runs bare: it is what brings the manager in
when the machine lacks it. The installer drops the manager in ~/.local/bin and
says so; if that directory is not on your PATH, add it once —
export PATH="$HOME/.local/bin:$PATH" — and every command above works as
written. make deps runs a second time as a no-op, naming the version it found.
Each mutating target carries the Apply gate. It renders what it is about to do —
the saved plan for the Guest and Edge stacks, the --check --diff run for the
Service layer — then asks you to type a word, and acts on what it just rendered.
Any other answer aborts and changes nothing. The gate is an attention gate, not
an authorisation boundary: it catches the wrong place, not the wrong person.
guest, service and edge also take NONINTERACTIVE=1 on the command line,
for a run with no hand at the keyboard. For guest and edge the plan check
judges the rendered artifact in the word's place, and the Target acts only on a
clean judgement, so a plan that would destroy or replace anything acts on
nothing. That judgement needs a baseline to stand on, and a State that holds no
managed resource is none: a plan made against one is red rather than empty,
whether tofu show -json writes no prior_state for it (no resources and no
outputs) or writes one that holds only outputs or data sources, because every
resource then plans as a create and a replacement is indistinguishable from a
first create. The resources are looked for in the root module and in every
module under it. For service the
gate is the rehearsal it has just run — a playbook cannot replace a Guest — so a
rehearsal that fails stops it before the real run. That rehearsal does not run
the playbook's command: tasks (the migrations, and the account checks and
creates), so it does not show what they would change. Only a command-line
assignment activates the mode: an exported NONINTERACTIVE=1 still asks
for the word, because the word exists to make a person look.
make prod NONINTERACTIVE=1 hands the mode to every step it runs.
make snapshot is the exception, and the one write that comes before the rest:
it takes the restore point a gated change relies on, so it carries no gate and a
deploy runs it unattended as its first step. The vmid is read out of the Guest
Stack's state and never typed, so it can only aim at the Guest this repository
records; it deletes every predeploy-* beyond the newest three, each by its
explicit name, and a snapshot named anything else is never touched, whoever took
it. A snapshot that cannot be taken is a red step, so nothing changes after it.
Repository overview
vikunja/guest/ the Guest · vikunja/service/ the Service · npm/ the Edge ·
docs/ the detailed documentation — docs/reference/ a page per layer,
the state, the deploy and
the hardening,
docs/adr/ the decisions.
For agents
Read AGENTS.md: the working context for this repository.
License
MIT — see LICENSE.