Files
linux-workstations/docs/postinstall-ansible.md

89 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

# Postinstall via Ansible
Voraussetzung: Debian-Grundinstallation läuft, SSH-Login per Key funktioniert (siehe `installation.md`).
## 1. Ansible auf dem Admin-Rechner
Ansible kann von **jedem Rechner** ausgeführt werden, der die Zielmaschinen per SSH erreicht und Python 3 hat. Empfohlen: die erste fertige Linux-Workstation wird zum Admin-Rechner für die nächsten.
Initial vom Windows-Rechner (WSL/Git-Bash) reicht auch:
```bash
# Linux/WSL
sudo apt install -y ansible
# oder via pipx
pipx install ansible-core
```
## 2. Ablauf
```bash
cd ~/Claude/linux-workstations
# Verbindungstest
ansible -i ansible/inventory.yml notebook -m ping
# Trockenlauf
ansible-playbook -i ansible/inventory.yml ansible/site.yml --limit notebook --check --diff
# Echter Run
ansible-playbook -i ansible/inventory.yml ansible/site.yml --limit notebook
```
Die Playbook-Ausführung dauert beim ersten Mal ~20 min (KDE-Plasma-Pakete sind groß).
## 3. Was nach `site.yml` fertig ist
- Debian-Basis mit allen Updates, deutsche Locale, Zeitzone Berlin
- KDE Plasma 6 + SDDM (Login-Manager) — Reboot fällig
- SSH gehärtet (Key-only), UFW aktiv (nur SSH offen), `unattended-upgrades` an
- Git, Node.js, Python, Editor, Browser, LibreOffice, Codecs
- **Claude Code + ccusage installiert, `~/.claude/settings.json` mit Statusline gesetzt**
- **`~/Claude` geklont (`--recurse-submodules`)**, Git-User auf `egon` konfiguriert
- SSH-Key für Gitea generiert (`~/.ssh/id_ed25519_gitea`), `known_hosts` für `docker.egonlebt.lan:2222` vorpopuliert
## 4. Restmanuelle Schritte
Diese zwei Dinge muss man pro Maschine selbst tun — beides je 1 Minute.
### 4.1 SSH-Public-Key auf Gitea hochladen
Am Ende des Ansible-Runs zeigt die Rolle `claude_workspace` den Public-Key an. Wenn der Run schon vorbei ist:
```bash
ssh tom@notebook 'cat ~/.ssh/id_ed25519_gitea.pub'
```
→ in <http://docker.egonlebt.lan:3000/user/settings/keys> als neuen SSH-Key einfügen, Name z.B. `notebook-tom`.
Danach auf dem Zielrechner einmal:
```bash
ssh -i ~/.ssh/id_ed25519_gitea -T git@docker.egonlebt.lan -p 2222
# Antwort: "Hi there, egon! You've successfully authenticated…"
```
### 4.2 Claude Code anmelden
Direkt am Zielrechner (oder per `ssh -t`):
```bash
claude
# → folgt dem Browser-Login-Flow einmalig
```
Danach ist die Maschine voll einsatzbereit. Statusline, Hooks (Auto-Pull beim Start, Auto-Commit/Push beim Stop), MCP-Server (paperless, imap, ssh-infra) — alles aktiv, weil Konfiguration im Repo liegt.
## 5. Wartung
```bash
# Alles aktualisieren (nur APT-Pakete + Konfig-Drift heilen):
ansible-playbook -i ansible/inventory.yml ansible/site.yml
# Eine einzelne Rolle:
ansible-playbook -i ansible/inventory.yml ansible/site.yml --tags claude_workspace
# Eine einzelne Maschine:
ansible-playbook -i ansible/inventory.yml ansible/site.yml --limit werkstatt
```