# 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//docker-compose.yml`. ## Layout (planned) `inventory/{hosts.yml,group_vars/}`, `roles/{docker_stack,script,lxc_base}`, `stacks//{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//` 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 and remove its Watchtower label. - 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 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. Merging deploys: a push to `main` that touches the paths in `.gitea/workflows/deploy-stacks.yaml` runs the stacks playbook, so allowing the merge prompt is also my OK to deploy. ## 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.