54 Semaphore Installation und Grundkonfiguration

54.1 Systemanforderungen

54.1.1 Unterstützte Betriebssysteme

Semaphore ist plattformübergreifend verfügbar und unterstützt:

54.1.2 Benötigte Datenbanken

Semaphore erfordert eine relationale Datenbank zur Persistierung:

Empfehlung: PostgreSQL für Produktionsumgebungen aufgrund besserer Performance und Stabilität.

54.1.3 Dependencies

54.1.3.1 Erforderliche Komponenten

54.1.3.2 Optional

54.1.4 Ressourcenvoraussetzungen

54.1.4.1 Minimale Anforderungen

54.1.4.2 Empfohlene Anforderungen

54.2 Deployment-Varianten

54.2.1 Direkte Installation per Binary

54.2.1.1 Vorteile

54.2.1.2 Nachteile

54.2.1.3 Installationsschritte

# Download der aktuellen Version
wget https://github.com/ansible-semaphore/semaphore/releases/latest/download/semaphore_linux_amd64

# Ausführbar machen und verschieben
chmod +x semaphore_linux_amd64
sudo mv semaphore_linux_amd64 /usr/local/bin/semaphore

# Verify installation
semaphore version

54.2.2 Installation über Docker-Container

54.2.2.1 Vorteile

54.2.2.2 Nachteile

54.2.2.3 Docker Compose Setup

version: '3'
services:
  semaphore:
    image: semaphoreui/semaphore:latest
    ports:
      - "3000:3000"
    environment:
      SEMAPHORE_DB_DIALECT: postgres
      SEMAPHORE_DB_HOST: postgres
      SEMAPHORE_DB_PORT: 5432
      SEMAPHORE_DB_USER: semaphore
      SEMAPHORE_DB_PASS: semaphore_password
      SEMAPHORE_DB_NAME: semaphore
      SEMAPHORE_ADMIN_PASSWORD: admin_password
      SEMAPHORE_ADMIN_NAME: admin
      SEMAPHORE_ADMIN_EMAIL: admin@example.com
    depends_on:
      - postgres
    volumes:
      - ./semaphore:/etc/semaphore

  postgres:
    image: postgres:13
    environment:
      POSTGRES_USER: semaphore
      POSTGRES_PASSWORD: semaphore_password
      POSTGRES_DB: semaphore
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

54.2.3 Bereitstellung in Kubernetes via Helm-Chart

54.2.3.1 Vorteile

54.2.3.2 Nachteile

54.2.3.3 Helm Installation

# Helm Repository hinzufügen
helm repo add semaphore https://ansible-semaphore.github.io/semaphore

# Chart installieren
helm install semaphore semaphore/semaphore \
  --set config.database.dialect=postgres \
  --set config.database.host=postgres-service \
  --set config.admin.name=admin \
  --set config.admin.email=admin@example.com

54.2.4 Deployment-Vergleich

Kriterium Binary Docker Kubernetes
Einfachheit Hoch Mittel Niedrig
Skalierbarkeit Niedrig Mittel Hoch
Wartungsaufwand Hoch Mittel Niedrig
Isolation Niedrig Hoch Sehr hoch
Performance Sehr hoch Hoch Mittel

54.3 Erste Einrichtung

54.3.1 Datenbank-Setup

54.3.1.1 PostgreSQL Konfiguration

-- Datenbank und Benutzer erstellen
CREATE DATABASE semaphore;
CREATE USER semaphore WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE semaphore TO semaphore;

-- Verbindung testen
\c semaphore semaphore

54.3.1.2 MySQL Konfiguration

-- Datenbank und Benutzer erstellen
CREATE DATABASE semaphore CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'semaphore'@'%' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON semaphore.* TO 'semaphore'@'%';
FLUSH PRIVILEGES;

54.3.2 Konfigurationsdateien

54.3.2.1 Struktur und Speicherorte

/etc/semaphore/
├── config.json          # Hauptkonfiguration
├── credentials/          # Credential-Dateien
└── repositories/         # Git-Repository-Cache

54.3.2.2 Beispiel-Konfiguration

{
  "port": ":3000",
  "host": "0.0.0.0",
  "web_host": "https://semaphore.example.com",
  "cookie_hash": "generate-32-character-random-string",
  "cookie_encryption": "generate-32-character-random-string",
  "access_key_encryption": "generate-32-character-random-string",
  
  "db_dialect": "postgres",
  "db_host": "localhost:5432",
  "db_user": "semaphore",
  "db_pass": "secure_password",
  "db_name": "semaphore",
  
  "email_sender": "semaphore@example.com",
  "email_host": "smtp.example.com",
  "email_port": "587",
  
  "ldap_enable": false,
  "ssh_config_path": "/etc/semaphore/ssh_config",
  
  "telegram_chat": "",
  "telegram_token": "",
  
  "slack_url": "",
  
  "max_parallel_tasks": 10
}

54.3.2.3 Wichtigste Parameter

54.3.3 Admin-User Erstellung

54.3.3.1 Interaktive Konfiguration

# Initiales Setup starten
semaphore setup

# Folgende Eingaben werden abgefragt:
# - Database dialect (postgres/mysql)
# - Database connection details
# - Admin user credentials
# - Playbook path
# - Web host URL

54.3.3.2 Automatisierte Konfiguration

# Umgebungsvariablen setzen
export SEMAPHORE_DB_DIALECT=postgres
export SEMAPHORE_DB_HOST=localhost:5432
export SEMAPHORE_DB_USER=semaphore
export SEMAPHORE_DB_PASS=secure_password
export SEMAPHORE_DB_NAME=semaphore
export SEMAPHORE_ADMIN_PASSWORD=admin_password
export SEMAPHORE_ADMIN_NAME=admin
export SEMAPHORE_ADMIN_EMAIL=admin@example.com

# Setup ausführen
semaphore setup --non-interactive

54.3.4 Service-Start und erster Zugriff

54.3.4.1 Systemd Service (Linux)

# /etc/systemd/system/semaphore.service
[Unit]
Description=Semaphore Ansible Web UI
After=network.target

[Service]
Type=simple
User=semaphore
Group=semaphore
WorkingDirectory=/opt/semaphore
ExecStart=/usr/local/bin/semaphore service --config /etc/semaphore/config.json
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

54.3.4.2 Service-Management

# Service aktivieren und starten
sudo systemctl enable semaphore
sudo systemctl start semaphore

# Status überprüfen
sudo systemctl status semaphore

# Logs anzeigen
sudo journalctl -u semaphore -f

54.3.4.3 Erster Webzugriff

# Browser öffnen
http://localhost:3000

# Login mit Admin-Credentials
# Username: admin (oder konfigurierter Name)
# Password: admin_password (oder konfiguriertes Passwort)

54.4 Authentifizierung

54.4.1 Lokale Benutzerverwaltung

54.4.1.1 Charakteristika

54.4.1.2 Konfiguration

{
  "email_alert": true,
  "email_sender": "semaphore@example.com",
  "password_login_disable": false,
  "non_admin_can_create_project": false
}

54.4.2 LDAP-Integration

54.4.2.1 Vorteile

54.4.2.2 Konfiguration

{
  "ldap_enable": true,
  "ldap_host": "ldap.example.com:389",
  "ldap_bind_dn": "CN=semaphore,OU=ServiceAccounts,DC=example,DC=com",
  "ldap_bind_password": "service_password",
  "ldap_search_dn": "OU=Users,DC=example,DC=com",
  "ldap_search_filter": "(&(objectClass=user)(memberOf=CN=Semaphore-Users,OU=Groups,DC=example,DC=com))",
  "ldap_mapping_username": "sAMAccountName",
  "ldap_mapping_fullname": "displayName",
  "ldap_mapping_email": "mail"
}

54.4.3 OAuth/OpenID Connect

54.4.3.1 Unterstützte Provider

54.4.3.2 GitHub OAuth Konfiguration

{
  "git_hub_oauth": {
    "enabled": true,
    "client_id": "github_client_id",
    "client_secret": "github_client_secret",
    "redirect_url": "https://semaphore.example.com/auth/github/callback"
  }
}

54.4.4 Authentifizierungs-Vergleich

Methode Komplexität Sicherheit Integration Wartung
Lokal Niedrig Mittel Keine Hoch
LDAP Mittel Hoch Gut Mittel
OAuth/OIDC Mittel Hoch Sehr gut Niedrig

54.4.4.1 Empfehlungen