3.8 KiB
3.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Repository Overview
This is a multi-environment infrastructure-as-code repository managing:
- Ansible: Configuration management for servers across multiple environments (VNTX, home, app servers)
- Terraform: DNS infrastructure management across DNSimple, Porkbun, and PowerDNS
- Kubernetes: K3s cluster deployments on Proxmox with Flatcar/Debian
- Home Lab: K3s configurations with Tailscale integration
Common Commands
Ansible Operations
# Run main playbook
cd ansible && ./run.sh
# Bootstrap new host
make bootstrap-init HOSTNAME=hostname ANSIBLE_HOST=ip_address
# Run specific playbook
ansible-playbook general.yml
# Run with specific tags
ansible-playbook -t caddy general.yml
# Gather facts from all hosts
make facts
Terraform Operations
cd terraform
terraform init
terraform plan
terraform apply
# Format terraform files before committing
terraform fmt
K3s Cluster Deployment (VNTX)
cd clusters/vntx
export TF_VAR_proxmox_password="your-password"
./deploy.sh
# Manual steps if needed:
cd terraform && tofu apply
cd ../ansible && ansible-playbook -i inventory.yml k3s-install.yml
export KUBECONFIG=./kubeconfig
kubectl get nodes
Architecture
Directory Structure
-
ansible/- Ansible playbooks and roles for server configurationroles/- Reusable roles (base, caddy, docker, k3s, resolvers, etc.)group_vars/- Group-specific variableshost_vars/- Host-specific variables- Main playbooks:
playbook.yml,general.yml,bootstrap.yml
-
terraform/- DNS infrastructure management- Manages domains: w5isp.com, vntx.net/org, manero.org, mcintire.me, gridmap.org
- Providers: DNSimple, Porkbun, PowerDNS (reverse DNS)
-
clusters/vntx/- K3s cluster on Proxmoxterraform/- VM provisioning on Proxmoxansible/- K3s installation and configurationinfrastructure/- Services like Icinga2, FreeRADIUS, Unboundsystem/- Core services: MetalLB, Longhorn, cert-manager
-
home/- Home lab K3s configurationsk3s/- K3s service definitions with Tailscale integrationcluster/- Application deployments (Forgejo, Node-RED, etc.)
Key Infrastructure Services
Monitoring: Icinga2 with MariaDB backend DNS: Unbound resolvers, PowerDNS for reverse zones VPN: Tailscale integration across environments Web Proxy: Caddy for reverse proxy and SSL termination Storage: Longhorn distributed storage for K3s Load Balancing: MetalLB for bare-metal K3s
Security Notes
- Ansible user (UID 10001) with passwordless sudo
- SSH keys fetched from GitHub for authentication
- Tailscale requires
TAILSCALE_KEYenvironment variable - Terraform credentials should use environment variables (TF_VAR_*)
Development Workflow
Adding New Hosts
- Add host to
ansible/hostsinventory - Create host_vars file if needed
- Run bootstrap:
make bootstrap-init HOSTNAME=x ANSIBLE_HOST=y - Apply configuration:
ansible-playbook -l hostname general.yml
DNS Changes
- Edit appropriate
terraform/dns_*.tffile - Run
terraform fmtto format - Review with
terraform plan - Apply with
terraform apply
K3s Service Deployment
- Create namespace if needed
- Deploy storage (PVC) if stateful
- Create ConfigMaps/Secrets
- Deploy application
- Configure Service/Ingress for access
Testing
Ansible
# Syntax check
ansible-playbook --syntax-check playbook.yml
# Dry run
ansible-playbook --check playbook.yml
# Test on specific host
ansible-playbook -l hostname playbook.yml
Terraform
terraform validate
terraform plan
Kubernetes
kubectl apply --dry-run=client -f manifest.yaml
kubectl diff -f manifest.yaml