51 lines
2.8 KiB
Markdown
51 lines
2.8 KiB
Markdown
# ansible
|
||
|
||
Ansible repository to manage the homelab (`../homelab-session-summary-*.md`).
|
||
Everything is reached over WireGuard, so bring the tunnel up first.
|
||
|
||
## Run it from Docker
|
||
|
||
Ansible runs in a container so it never touches the laptop's own Ansible,
|
||
Python or collections (ViaRézo, kubic…).
|
||
|
||
```bash
|
||
source ansible-docker.sh
|
||
ansible-docker build # once, and after changing requirements*
|
||
ansible-docker run # shell in the repo, then ansible-playbook …
|
||
ansible-docker run ansible-playbook playbooks/utils.yml -CD
|
||
```
|
||
|
||
The container uses the host network (for `wg0`) and your SSH agent, reads
|
||
`~/.ssh/known_hosts` without writing to it, and mounts this repo, so edits are
|
||
live and `kube/config` lands here.
|
||
|
||
Without Docker: `uv venv env && uv pip install -p env/bin/python -r requirements.txt`,
|
||
then `env/bin/ansible-galaxy collection install -r requirements.yml -p .ansible/collections`.
|
||
|
||
## Inventory (`inventories/hosts.yml`)
|
||
|
||
| Group | What | Connects as |
|
||
|---|---|---|
|
||
| `hypervisors` | Proxmox host `10.0.0.1` | root |
|
||
| `lxc` | 100–106, 108–110, 250 | root (110 through `pct exec` on the host) |
|
||
| `vm` | 107 pelican-panel + the `k3s` VMs | root, k3s nodes as `un-oeil` + sudo |
|
||
| `k3s` | `k3s_masters` 131–133, `k3s_workers` 141–143 | `un-oeil` + sudo |
|
||
| `external` | `viarezo`, the ViaRézo VM `10.10.10.3` | root |
|
||
|
||
`host_type` (`lxc`, `vm`, `proxmox`, `external`) is what the playbooks test to
|
||
treat containers and VMs differently.
|
||
|
||
## Playbooks
|
||
|
||
Always dry-run first: `-CD` (`--check --diff`).
|
||
|
||
| Playbook | Does |
|
||
|---|---|
|
||
| `utils.yml` | Settings in `group_vars/all/utils.yml`. apt sources → `prism.viarezo.fr`; CLI tools (ViaRézo's list + a few); en_US/fr_FR locales; Europe/Paris; journald capped (200M, host 1G); sshd keys-only (`sshd -t` before reload); hostname = inventory name (LXC through `pct set`, never k3s/host); motd. VMs only: guest agent, NTP, fstrim. Host: pve-no-subscription repo, udp/443 → WireGuard saved in `rules.v4`. Docker hosts: weekly dangling-image prune. Tags let you run parts (`--tags ssh`). `--tags upgrade -l <hosts>`: full-upgrade one host at a time (never the Proxmox host); `-e utils_reboot=true` reboots VMs that need it, never LXCs. |
|
||
| `add_user.yml` | Accounts from `inventories/group_vars/all/users.yml`: create, keys (exact list), passwordless sudo, remove. Skips system accounts of the same name (Forgejo's `un-oeil`). |
|
||
| `deploy_kube.yml` | Longhorn prerequisites on workers, k3s install/upgrade/config one node at a time (init master → masters → workers), writes `kube/config`. Bump `k3s_version` in `group_vars/k3s.yml` to upgrade. |
|
||
|
||
## Secrets
|
||
|
||
`vault/password` (gitignored) holds the vault password. Nothing is vaulted yet;
|
||
the k3s join token is read from the first master. `kube/config` is gitignored.
|