Files
customer-installer/TODO.md
Wolfgang aa00fb9d29 feat: Add credentials management system and comprehensive testing
- Add credentials management system with automatic saving and updates
- Add upload form URL to JSON output
- Add Ollama model information to JSON output
- Implement credential update system (update_credentials.sh)
- Implement credential save system (save_credentials.sh)
- Add comprehensive test suites (infrastructure, n8n, PostgREST, complete system)
- Add workflow auto-reload system with systemd service
- Add detailed documentation (CREDENTIALS_MANAGEMENT.md, TEST_REPORT.md, VERIFICATION_SUMMARY.md)
- Improve n8n setup with robust API-based workflow import
- Add .gitignore for credentials directory
- All tests passing (40+ test cases)

Key Features:
- Credentials automatically saved to credentials/<hostname>.json
- Update Ollama URL from IP to hostname without container restart
- Comprehensive testing with 4 test suites
- Full documentation and examples
- Production-ready system
2026-01-24 22:31:26 +01:00

144 lines
4.7 KiB
Markdown

# n8n Customer Provisioning System
## Status: ✅ Phase 1-4 Complete
---
## Implementierte Features
### Phase 1: n8n API Funktionen (libsupabase.sh)
- [x] `n8n_api_login()` - Login mit `emailOrLdapLoginId` (nicht `email`)
- [x] `n8n_api_create_postgres_credential()` - PostgreSQL Credential erstellen
- [x] `n8n_api_create_ollama_credential()` - Ollama Credential erstellen
- [x] `n8n_api_import_workflow()` - Workflow importieren
- [x] `n8n_api_activate_workflow()` - Workflow aktivieren mit `versionId`
- [x] `n8n_generate_rag_workflow_json()` - Built-in Workflow Template
- [x] `n8n_setup_rag_workflow()` - Hauptfunktion für komplettes Setup
### Phase 2: install.sh - Workflow Import
- [x] Login durchführen
- [x] PostgreSQL Credential erstellen und ID speichern
- [x] Ollama Credential erstellen und ID speichern
- [x] Workflow JSON mit korrekten Credential-IDs generieren
- [x] Workflow importieren
- [x] Workflow aktivieren mit `POST /rest/workflows/{id}/activate` + `versionId`
### Phase 3: Externe Workflow-Datei Support
- [x] `--workflow-file <path>` Option hinzugefügt (default: `RAGKI-BotPGVector.json`)
- [x] `--ollama-model <model>` Option hinzugefügt (default: `ministral-3:3b`)
- [x] `--embedding-model <model>` Option hinzugefügt (default: `nomic-embed-text:latest`)
- [x] Python-Script für dynamische Credential-ID-Ersetzung
- [x] Entfernung von `id`, `versionId`, `meta`, `tags`, `active`, `pinData` beim Import
- [x] `RAGKI-BotPGVector.json` als Standard-Workflow-Template
### Phase 4: Tests & Git
- [x] Container sb-1769174647 - Workflow aktiviert ✅
- [x] Container sb-1769180683 - Externe Workflow-Datei ✅
- [x] Git Commits gepusht
---
## Verwendung
### Standard-Installation (mit Default-Workflow)
```bash
bash install.sh --debug
```
### Mit benutzerdefiniertem Workflow
```bash
bash install.sh --debug \
--workflow-file /path/to/custom-workflow.json \
--ollama-model "llama3.2:3b" \
--embedding-model "nomic-embed-text:v1.5"
```
### Verfügbare Optionen
| Option | Default | Beschreibung |
|--------|---------|--------------|
| `--workflow-file` | `RAGKI-BotPGVector.json` | Pfad zur n8n Workflow JSON-Datei |
| `--ollama-model` | `ministral-3:3b` | Ollama Chat-Modell |
| `--embedding-model` | `nomic-embed-text:latest` | Ollama Embedding-Modell |
---
## Technische Details
### n8n REST API Endpoints
| Endpoint | Methode | Beschreibung |
|----------|---------|--------------|
| `/rest/login` | POST | Login (Feld: `emailOrLdapLoginId`, nicht `email`) |
| `/rest/credentials` | POST | Credential erstellen |
| `/rest/workflows` | POST | Workflow importieren |
| `/rest/workflows/{id}/activate` | POST | Workflow aktivieren (benötigt `versionId`) |
### Credential Types
- `postgres` - PostgreSQL Datenbank
- `ollamaApi` - Ollama API
### Workflow-Verarbeitung
Das Python-Script `/tmp/process_workflow.py` im Container:
1. Liest die Workflow-Template-Datei
2. Entfernt Felder: `id`, `versionId`, `meta`, `tags`, `active`, `pinData`
3. Ersetzt alle `postgres` Credential-IDs mit der neuen ID
4. Ersetzt alle `ollamaApi` Credential-IDs mit der neuen ID
5. Schreibt die verarbeitete Workflow-Datei
---
## Git Commits
1. `ff1526c` - feat: Auto-import n8n RAG workflow with credentials
2. `f663708` - fix: Workflow activation with versionId
3. `26f5a73` - feat: External workflow file support with dynamic credential replacement
---
## Phase 5: Workflow Auto-Reload bei LXC-Neustart ✅
- [x] Systemd-Service für automatisches Workflow-Reload
- [x] Reload-Script mit vollständigem Logging
- [x] Workflow-Template persistent speichern
- [x] Integration in install.sh
- [x] Hilfsfunktionen in libsupabase.sh
- [x] Dokumentation (WORKFLOW_RELOAD_README.md)
### Details
Der Workflow wird jetzt bei jedem LXC-Neustart automatisch neu geladen:
1. **Systemd-Service**: `/etc/systemd/system/n8n-workflow-reload.service`
2. **Reload-Script**: `/opt/customer-stack/reload-workflow.sh`
3. **Workflow-Template**: `/opt/customer-stack/workflow-template.json`
4. **Logs**: `/opt/customer-stack/logs/workflow-reload.log`
**Funktionsweise**:
- Beim LXC-Start wird der Systemd-Service ausgeführt
- Service wartet auf Docker und n8n-Container
- Reload-Script löscht alten Workflow
- Importiert Workflow aus Template
- Aktiviert Workflow
- Loggt alle Aktionen
**Siehe**: `WORKFLOW_RELOAD_README.md` für vollständige Dokumentation
---
## Nächste Schritte (Optional)
- [ ] Workflow-Validierung vor Import
- [ ] Mehrere Workflows unterstützen
- [ ] Workflow-Update bei bestehenden Containern
- [ ] Backup/Export von Workflows
- [ ] Tests für Auto-Reload-Feature durchführen