4.1 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What this is
Ansible playbooks for a homelab: Ubuntu VMs on a Proxmox host (rimeru), a TrueNAS box (veldora), and a Checkmk monitoring server (shion). There are no roles and no ansible.cfg. Everything is a standalone playbook in playbooks/. README.md is the human-facing overview: setup, the playbook table, and the steps for adding a host.
Setup and commands
./init.sh # creates ./venv, installs requirements.txt (proxmoxer, requests) and Galaxy collections
ansible-galaxy collection install -r requirements.yml # collections only: community.proxmox, checkmk.general
Ansible itself is not in requirements.txt. It must already be installed on the machine.
Without an ansible.cfg, you always pass the inventory explicitly. Use the directory so both inventory files and group_vars/host_vars get loaded:
ansible-playbook -i inventory/ playbooks/<playbook>.yml --ask-vault-pass
ansible-playbook -i inventory/ playbooks/<playbook>.yml --syntax-check
ansible-playbook -i inventory/ playbooks/<playbook>.yml --check --limit <host>
ansible-vault edit inventory/group_vars/all/vault.yml
The # noqa: annotations in the playbooks are for ansible-lint (ansible-lint playbooks/).
Inventory layout
inventory/homelabholds the infrastructure groups:ubuntu(all Ubuntu VMs),docker,kubernetes,proxmox,truenas.inventory/monitoringholds the Checkmk groups:sites(Checkmk servers) andagents(hosts that run the Checkmk agent). When you add a host to the homelab, it usually also goes intoagents(see README for the full steps).inventory/group_vars/all/holds the API connection vars for both Proxmox and Checkmk (servers.yml) plusvault.yml, which is Ansible Vault–encrypted and holds the matching secrets (proxmox_api_token_secret,checkmk_api_secret). They live underall(notsites) so theubuntuhosts inupdate-debian.ymlcan reach the Checkmk API vars too. Secrets go in vault files, not inline in playbooks.inventory/host_vars/<fqdn>.ymlfor a Checkmk server setscheckmk_sites(the list of OMD site names to manage) andvmid. No playbook readsvmidyet. The snapshot task finds the VM by name instead.
Playbook notes
-
update-checkmk.ymlhas three plays that share state through a fact:- On
allhosts, delegated to localhost, it gets the latest stable Checkmk tag from GitHub withgit ls-remoteand setscheckmk_version. It targetsallon purpose: aset_factonly applies to the hosts in its own play, sositesandagentswould lose the fact if the play ran only onlocalhost(or they'd have to readhostvars['localhost'].checkmk_version). - On
sites, it snapshots the VM through the Proxmox API (delegated to localhost, usinginventory_hostname_shortas the Proxmox VM name), installs the community-edition.deb, then runsomd stop,backup,updateandstartfor each entry incheckmk_sites. - On
agents, it installs the agent.debfrom the local Checkmk server (checkmk.stuyckv.com/local).
Package installs only run when
ansible_facts.lsb.id == 'Ubuntu'. - On
-
update-debian.ymlruns againstubuntu. It sets a Checkmk downtime throughcheckmk.general, then runs dist-upgrade, reboots if needed and autoremoves. Like the Proxmox snapshot, the downtime task is delegated to localhost withbecome: false. -
install-kubernetes.yml(untested) prepares thekubernetesgroup with Docker CE, containerd and kubeadm/kubelet/kubectl pinned to the v1.35 repo. The untrackedinstall-kube.shis the shell version it was ported from.
Conventions
- Newer playbooks use FQCN module names (
ansible.builtin.*) and the boolean literalstrue/false(notyes/no).install-kubernetes.ymldoesn't follow either yet, andupdate-debian.ymlstill has someyes/no. - Shell/command tasks set
changed_whenexplicitly. - Managed hosts are reached as the
ansibleuser with passwordless sudo, set up bycreate-ansibleuser.sh. It authorizes anansible@semaphorekey, so the playbooks are also run from Ansible Semaphore.