The first review found ways around the hook: unexpected errors exited with non-blocking codes, unusual spellings of the merge path skipped it, and an older pass outlived a newer fail. The ask rule for merges is back as a second layer, so merging outside /merge is enforced, not just instructed.
3.3 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 todocker.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
ansibleLXC.
Secrets
- The real vault file and password live in
/etc/homelab-ansible/on theansibleLXC, never in git. Commit onlyvault.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 call asks for permission (also inside /merge), and .claude/hooks/guard-merge.sh refuses it unless the PR's newest review comment is a pass for its head commit. 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.