Files
homelab-ansible/CLAUDE.md
kasun 2d24f767e1
Checks / Secret Scan (pull_request) Successful in 5s
Checks / Lint (pull_request) Successful in 9s
feature: add ansible foundation and connectivity check
First read-only run on the dedicated ansible runner proves the inventory, SSH access and Docker on the docker host before any stack is adopted.
2026-11-25 20:20:37 +01:00

2.9 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 only, and ask before opening or merging one. Reading from Gitea is free.

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.