Getting started¶
One-time setup, from a workstation with root SSH access to the Proxmox nodes.
1. Tools¶
git clone git@github.com:jwklijnsma/infra.git && cd infra
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
ansible-galaxy collection install -r requirements.yml
mkdir -p ~/.config/infra && read -rs P && printf '%s' "$P" > ~/.config/infra/vault-pass && chmod 600 ~/.config/infra/vault-pass
Store the same vault password as GitHub secret ANSIBLE_VAULT_PASSWORD
(Settings → Secrets and variables → Actions).
2. Deploy key for the runner¶
ssh-keygen -t ed25519 -C jwklijnsma/infra -f ~/.ssh/infra_deploy -N ''
Put the public key in infra_ssh_public_key (inventory/group_vars/all/main.yml) and the
private key in the vault as vault_infra_ssh_private_key.
3. Secrets¶
cp inventory/group_vars/all/vault.yml.example inventory/group_vars/all/vault.yml
$EDITOR inventory/group_vars/all/vault.yml # values from AliasVault
ansible-vault encrypt inventory/group_vars/all/vault.yml
CI refuses to run if vault.yml is committed unencrypted.
4. Proxmox API users + tokens (all 4 endpoints)¶
ansible-playbook playbooks/bootstrap_pve.yml # add -k if the nodes need a root password
# or, without a workstation: Actions -> bootstrap -> Run workflow (pushes branch bootstrap/pve-tokens, merge it)
git add inventory && git commit -m "pve: api tokens" && git push
This creates ansible@pve (PVEAdmin) and prometheus@pve (PVEAuditor) with API tokens on
node01, node02, home-cluster and node08, writes the vault-encrypted secrets into
inventory/1x-*.proxmox.yml and inventory/group_vars/all/pve_token_*.yml, and installs the
deploy key on every node. Check discovery:
ansible-inventory --graph
5. Runner LXC¶
The runner is CT 166 (gh-runner) on node04, created with the community-scripts
installer and renamed:
# on node04 (only needed when (re)creating it by hand)
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/github-runner.sh)"
pct set 166 --hostname gh-runner --memory 4096 && pct resize 166 rootfs 30G && pct reboot 166
provision.yml can recreate it from host_vars/gh-runner.yml if it is gone. Then, from a
workstation with the vault (the first run cannot go through CI, there is no runner yet):
ansible-playbook playbooks/runner.yml # registers it with label `homelab`, nginx for docs
The runner needs a fine-grained PAT (vault_github_runner_pat, Administration: read & write
on this repo) only for registration.
Project runners¶
The same LXC hosts one runner per own project (github_runner_projects in
host_vars/gh-runner.yml; personal accounts cannot share a runner across repos). They
run as user ghci with label projects and cannot read the Proxmox deploy key. Register
new ones with your own gh login (no PAT stored), then install the services:
scripts/register-project-runners.sh # every listed repo without a runner
ansible-playbook playbooks/runner.yml # or Semaphore "runner"
Workflows use runs-on: [self-hosted, projects]; public repos send fork PRs to
GitHub-hosted runners so outside code never runs in the LAN.
6. NetBox¶
Install it with the community-scripts installer on a home-cluster node shell:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/netbox.sh)"
Name the container netbox. Then create an API token in the NetBox UI (user → API tokens, write
enabled), store it as vault_netbox_token, and run playbooks/netbox.yml (enables /metrics).
7. Everything else¶
From now on GitHub does it — or run locally:
ansible-playbook playbooks/site.yml --check --diff # dry run
ansible-playbook playbooks/site.yml
| Workflow | When | What |
|---|---|---|
ci |
every PR / push | yamllint, ansible-lint, promtool, unit tests, mkdocs build --strict |
deploy |
push to main touching inventory/roles/playbooks, or manually |
site.yml (or a chosen playbook, --check optional) |
inventory-sync |
nightly 03:17 | facts → NetBox → docs, refresh exporters/targets/DNS, commit docs |
docs |
push touching docs/ |
build + publish to docs.home.janwiebe.eu |