Files
homelab-ansible/CLAUDE.md
T
kasun 737a3a29ec
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 12s
chore(claude): add merge skill with review gate
/merge takes changes from commit to merged PR in one run. A PreToolUse hook
refuses any merge without a passing review comment for the PR's current head
commit, so the review can't be skipped or go stale after new commits.
2026-11-27 03:27:38 +01:00

3.2 KiB

CLAUDE.md

Ansible automation for a Proxmox homelab. It deploys Docker stacks and single scripts into containers and LXCs, from git, through Gitea Actions.

Hosts

  • ansible: unprivileged LXC that runs Ansible and has SSH key access to docker.
  • docker: unprivileged LXC running Gitea, its Actions runner, Postgres and the apps. Compose files live in /home/pi/docker/<service>/docker-compose.yml.

Layout (planned)

inventory/{hosts.yml,group_vars/}, roles/{docker_stack,script,lxc_base}, stacks/<service>/{docker-compose.yml,env.j2}, scripts/, playbooks/, .gitea/workflows/.

Deployment flow

Branch → PR (lint, secret scan, later --check --diff) → merge to protected main → dedicated runner on the ansible LXC (runs-on: ansible) → playbook over SSH → restart only changed stacks → health check. Roll back with git revert.

Rules for stacks

  • Keep the /home/pi/docker/<service>/ paths, because Compose derives the project name from the folder.
  • Ansible manages config, never data. No ownership changes under DOCKER_DATA_ROOT (mapped UIDs).
  • When adopting a stack: pin its image, remove its Watchtower label, and require a no-change dry run first.
  • Gitea, its runner and Postgres never auto-deploy. I trigger them from the ansible LXC.

Secrets

  • The real vault file and password live in /etc/homelab-ansible/ on the ansible LXC, never in git. Commit only vault.example.yml.
  • This repo is meant to become public. Don't commit secrets, internal IPs or hostnames beyond the inventory aliases.

Live infrastructure

  • Don't change live systems (hosts, containers, Proxmox, Gitea settings) on your own initiative, even for small or reversible changes. Give me the exact steps and let me decide who runs them.
  • That includes ansible, ansible-playbook (even with --check), SSH and Docker commands against a host.
  • Code edits in the repo are fine without asking.
  • Never recreate a VM or LXC to apply a change.

Git conventions

Branch names, commit messages and PR titles follow @CONVENTIONS.md. The git hooks need git config core.hooksPath .githooks once per clone.

Only commit when I explicitly say "commit" for that change. A yes to a question that also mentioned committing is not enough; when unsure, ask.

The remote is a self-hosted Gitea, so gh doesn't work. For PRs and their CI status use .claude/scripts/gitea.sh (acts as claude-bot), e.g. .claude/scripts/gitea.sh GET '/repos/kasun/homelab-ansible/pulls?state=open'. Use it for PRs, and for issues when I ask. Reading from Gitea is free.

Open and merge PRs through /merge: typing it is my OK to commit, open a PR and merge for that run. Outside /merge, ask first. Every merge needs a passing review comment for the PR's head commit; .claude/hooks/guard-merge.sh refuses the merge otherwise. Before deploy-on-merge is enabled, revisit this: PRs that deploy will need my approval.

Verifying changes

Install the lint tools once with python3 -m venv .venv and .venv/bin/pip install -r requirements-dev.txt. After editing, run .venv/bin/yamllint --strict . and .venv/bin/ansible-lint, and show the output.

Don't silence a check to make it pass (# noqa, lint skip lists, git commit --no-verify) without a stated reason and my OK.