generated from GamingChaos/ansible-repository-template
50 lines
2.4 KiB
Markdown
50 lines
2.4 KiB
Markdown
# ansible-homelab
|
|
|
|
Ansible playbooks for managing the homelab. Most machines are Ubuntu VMs running on the Proxmox host `rimeru`, and `shion` runs Checkmk to monitor everything. The playbooks run from a workstation or from Ansible Semaphore.
|
|
|
|
## Setup
|
|
|
|
Ansible itself must already be installed. Then:
|
|
|
|
```sh
|
|
./init.sh
|
|
```
|
|
|
|
This creates a `venv/` with the Python dependencies (`proxmoxer`, `requests`) and installs the Galaxy collections from `requirements.yml` (`community.proxmox`, `checkmk.general`).
|
|
|
|
## Running a playbook
|
|
|
|
There's no `ansible.cfg`, so pass the inventory directory every time. API secrets are vault-encrypted, so you also need the vault password:
|
|
|
|
```sh
|
|
ansible-playbook -i inventory/ playbooks/update-debian.yml --ask-vault-pass
|
|
```
|
|
|
|
To dry-run against a single host first:
|
|
|
|
```sh
|
|
ansible-playbook -i inventory/ playbooks/update-debian.yml --ask-vault-pass --check --limit shion.stuyckv.local
|
|
```
|
|
|
|
## Playbooks
|
|
|
|
| Playbook | Hosts | What it does |
|
|
| --- | --- | --- |
|
|
| `update-debian.yml` | `ubuntu` | Schedules a one-hour Checkmk downtime, runs a dist-upgrade, reboots if needed and removes unused packages. |
|
|
| `update-checkmk.yml` | `sites`, `agents` | Finds the latest Checkmk release, snapshots the Checkmk VM in Proxmox, upgrades Checkmk and its OMD sites (taking a backup first), then updates the agent on every monitored host. |
|
|
| `install-kubernetes.yml` | `kubernetes` | Installs Docker CE, containerd, kubeadm, kubelet and kubectl (v1.35). **Not tested yet.** |
|
|
|
|
## Inventory
|
|
|
|
- `inventory/homelab`: hosts grouped by role (`ubuntu`, `docker`, `kubernetes`, `proxmox`, `truenas`).
|
|
- `inventory/monitoring`: the Checkmk server (`sites`) and the hosts that run the Checkmk agent (`agents`).
|
|
- `inventory/group_vars/all/servers.yml`: Proxmox and Checkmk API connection settings.
|
|
- `inventory/group_vars/all/vault.yml`: the API secrets, encrypted with Ansible Vault. Edit it with `ansible-vault edit inventory/group_vars/all/vault.yml`.
|
|
- `inventory/host_vars/`: per-host settings, such as the OMD sites to upgrade on the Checkmk server (`checkmk_sites`).
|
|
|
|
## Adding a host
|
|
|
|
1. On the new host, run `create-ansibleuser.sh` as root. It creates the `ansible` user with passwordless sudo and authorizes the workstation and Semaphore SSH keys.
|
|
2. Add the host to the matching groups in `inventory/homelab`.
|
|
3. Add the host to `agents` in `inventory/monitoring` so it gets the Checkmk agent.
|