docs: translate README to English and align structure
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
eb6be0e5fa
commit
1c6e48aaf0
1 file changed
+211
-90
@@ -1,27 +1,62 @@
|
|||||||
# MrBlake NetBox Plugin Store
|
# NetBox Plugin Store
|
||||||
|
|
||||||
Dieses Repository besteht aus drei getrennten Komponenten:
|
A self-hosted catalogue and installer for NetBox plugins. It syncs plugin
|
||||||
|
repositories, lets an administrator review and approve releases, and installs
|
||||||
|
approved releases on a NetBox host through a separate privileged agent.
|
||||||
|
|
||||||
| Pfad | Aufgabe |
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| **Type** | PHP web application, NetBox plugin and Linux host agent |
|
||||||
|
| **NetBox** | `4.6.5` – `4.6.8` (plugin) |
|
||||||
|
| **PHP** | `>=8.3` (store) |
|
||||||
|
| **Repository** | <https://git.mrblake.cc/MrBlake/Netbox-Store> |
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
| Path | Purpose |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `store/` | Eigenständiger PHP-Store, direkt durch Apache ausgeliefert. Er synchronisiert Forgejo-/GitHub-Repositories, rendert README-Dateien und stellt den kuratierten API-Katalog bereit. |
|
| `store/` | Standalone PHP store served directly by Apache. Syncs Forgejo/GitHub repositories, renders README files and provides the curated API catalogue. |
|
||||||
| `netbox_plugin/` | NetBox-Oberfläche für Katalog, Installation und Plugin-Lebenszyklus. Unterstützt NetBox 4.6.5 bis 4.6.8. |
|
| `netbox_plugin/` | NetBox UI for the catalogue, installation and plugin life cycle. Supports NetBox 4.6.5 to 4.6.8. |
|
||||||
| `host_agent/` | Kleine privilegierte Linux-Komponente, die freigegebene Artefakte prüft, Source-Archive lokal als Wheel baut und die Änderungen am NetBox-Host ausführt. |
|
| `host_agent/` | Small privileged Linux component that verifies approved artefacts, builds source archives into wheels locally and applies the changes on the NetBox host. |
|
||||||
|
|
||||||
Für NetBox-Hosts steht zusätzlich [`install.sh`](install.sh) bereit. Der interaktive Installer kann Plugin, Host-Agent, systemd-Socket, Requirements und den verwalteten Block in `configuration.py` in einem Durchlauf einrichten. Er startet standardmäßig im Dry-Run-Modus, legt vor Änderungen Backups an und verlangt für echte Lifecycle-Änderungen eine zusätzliche ausdrückliche Bestätigung.
|
For NetBox hosts there is also [`install.sh`](install.sh). This interactive
|
||||||
|
installer sets up the plugin, host agent, systemd socket, requirements and the
|
||||||
|
managed block in `configuration.py` in one run. It starts in dry-run mode by
|
||||||
|
default, makes backups before any change and requires an additional explicit
|
||||||
|
confirmation for real life-cycle changes.
|
||||||
|
|
||||||
Der Store verwendet standardmäßig eine lokale JSON-Datei. MariaDB ist optional. Die konfigurierte Standardquelle gilt als vom Betreiber freigegeben; weitere Quellen werden im Admin-Bereich zunächst ausstehend angelegt. Automatisch erkannte Plugins und Releases erscheinen erst nach einer ausdrücklichen Freigabe im öffentlichen Katalog.
|
The store uses a local JSON file by default; MariaDB is optional. The
|
||||||
|
configured default source is considered approved by the operator; further
|
||||||
|
sources are added as pending in the admin area. Automatically discovered
|
||||||
|
plugins and releases only appear in the public catalogue after explicit
|
||||||
|
approval.
|
||||||
|
|
||||||
## Native Installation mit Apache und JSON
|
## Features
|
||||||
|
|
||||||
Docker ist nicht erforderlich. Der primäre Betriebsweg ist eine normale PHP-Anwendung unter Apache. Benötigt werden:
|
- Sync of Forgejo/Gitea and GitHub repositories, including private GitHub
|
||||||
|
metadata with a token
|
||||||
|
- Plugin detail pages rendered from the README of a pinned commit
|
||||||
|
- Separate review and approval of sources, plugins and releases
|
||||||
|
- Public, approved-only catalogue API
|
||||||
|
- Source candidates for projects without a wheel release, pinned to the exact
|
||||||
|
commit
|
||||||
|
- NetBox plugin for browsing, installing and managing plugins
|
||||||
|
- Privileged host agent that re-checks approval, size and SHA-256 before every
|
||||||
|
change
|
||||||
|
|
||||||
- PHP 8.3 oder neuer mit CLI und Apache-Modul/FPM (getestet mit PHP 8.4);
|
## Installation of the store (Apache and JSON)
|
||||||
- die PHP-Erweiterungen cURL, DOM/XML, intl, JSON, mbstring und PDO; für MariaDB zusätzlich `pdo_mysql`;
|
|
||||||
|
Docker is not required. The primary deployment is a regular PHP application
|
||||||
|
under Apache. Requirements:
|
||||||
|
|
||||||
|
- PHP 8.3 or newer with CLI and Apache module/FPM (tested with PHP 8.4);
|
||||||
|
- PHP extensions cURL, DOM/XML, intl, JSON, mbstring and PDO; `pdo_mysql`
|
||||||
|
additionally for MariaDB;
|
||||||
- Composer 2;
|
- Composer 2;
|
||||||
- Apache 2.4 mit `mod_rewrite`; `mod_headers` wird für die zusätzlichen Header aus `.htaccess` empfohlen.
|
- Apache 2.4 with `mod_rewrite`; `mod_headers` is recommended for the extra
|
||||||
|
headers from `.htaccess`.
|
||||||
|
|
||||||
Unter Debian/Ubuntu sind die wesentlichen Pakete beispielsweise:
|
On Debian/Ubuntu the main packages are, for example:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
sudo apt install apache2 composer libapache2-mod-php8.3 php8.3-cli \
|
sudo apt install apache2 composer libapache2-mod-php8.3 php8.3-cli \
|
||||||
@@ -29,11 +64,14 @@ sudo apt install apache2 composer libapache2-mod-php8.3 php8.3-cli \
|
|||||||
sudo a2enmod rewrite headers expires
|
sudo a2enmod rewrite headers expires
|
||||||
```
|
```
|
||||||
|
|
||||||
Die Paketnamen anderer Distributionen unterscheiden sich. Bei PHP-FPM muss Apache stattdessen mit dem passenden FPM-Handler konfiguriert werden.
|
Package names differ on other distributions. With PHP-FPM, configure Apache
|
||||||
|
with the matching FPM handler instead.
|
||||||
|
|
||||||
### Anwendung und Konfiguration
|
### Application and configuration
|
||||||
|
|
||||||
Dieses Beispiel verwendet `/var/www/netbox-plugin-store` als Repository-Pfad. Nur `store/public` darf durch Apache veröffentlicht werden. Das Repository kann zunächst unter einem normalen Deployment-Benutzer ausgecheckt und danach an diesen Pfad verschoben werden:
|
This example uses `/var/www/netbox-plugin-store` as the repository path. Only
|
||||||
|
`store/public` may be published by Apache. Check out the repository as a
|
||||||
|
regular deployment user first, then move it into place:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
git clone https://git.mrblake.cc/MrBlake/Netbox-Store.git netbox-plugin-store
|
git clone https://git.mrblake.cc/MrBlake/Netbox-Store.git netbox-plugin-store
|
||||||
@@ -44,21 +82,23 @@ composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
|
|||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
```
|
```
|
||||||
|
|
||||||
Zuerst werden ein eigenes Admin-Passwort und ein unabhängiges Session-Geheimnis erzeugt:
|
Generate an admin password hash and an independent session secret:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
php bin/console hash-password 'EIN-LANGES-ZUFÄLLIGES-PASSWORT'
|
php bin/console hash-password 'A-LONG-RANDOM-PASSWORD'
|
||||||
php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'
|
php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'
|
||||||
```
|
```
|
||||||
|
|
||||||
Das Klartextpasswort sollte in der Praxis aus einer temporären, nicht protokollierten Shell-Variablen übergeben werden. In `store/.env` werden mindestens die folgenden Werte ersetzt. Der Argon2id-Hash steht in einfachen Anführungszeichen, damit seine `$`-Zeichen unverändert bleiben:
|
In practice, pass the plain-text password from a temporary, unlogged shell
|
||||||
|
variable. Replace at least the following values in `store/.env`. The Argon2id
|
||||||
|
hash is in single quotes so its `$` characters stay intact:
|
||||||
|
|
||||||
```dotenv
|
```dotenv
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
STORE_PUBLIC_URL=https://plugins.example.internal
|
STORE_PUBLIC_URL=https://plugins.example.com
|
||||||
STORE_COOKIE_SECURE=true
|
STORE_COOKIE_SECURE=true
|
||||||
|
|
||||||
STORE_ADMIN_USERNAME=mein-admin
|
STORE_ADMIN_USERNAME=my-admin
|
||||||
STORE_ADMIN_PASSWORD_HASH='$argon2id$...'
|
STORE_ADMIN_PASSWORD_HASH='$argon2id$...'
|
||||||
STORE_SESSION_SECRET=...
|
STORE_SESSION_SECRET=...
|
||||||
|
|
||||||
@@ -66,9 +106,12 @@ STORE_DB_DRIVER=json
|
|||||||
STORE_JSON_PATH=/var/www/netbox-plugin-store/store/data/store.json
|
STORE_JSON_PATH=/var/www/netbox-plugin-store/store/data/store.json
|
||||||
```
|
```
|
||||||
|
|
||||||
Bei einem reinen HTTP-Testsystem müssen URL und `STORE_COOKIE_SECURE=false` zusammenpassen. Ein extern erreichbarer Produktivbetrieb sollte TLS direkt in Apache terminieren.
|
On a plain-HTTP test system, the URL and `STORE_COOKIE_SECURE=false` must
|
||||||
|
match. A publicly reachable production instance should terminate TLS directly
|
||||||
|
in Apache.
|
||||||
|
|
||||||
Der Anwendungscode bleibt root-owned; nur `.env` ist für die Apache-Gruppe lesbar und nur `store/data` ist für den Web-/Scheduler-Benutzer schreibbar:
|
The application code stays root-owned; only `.env` is readable by the Apache
|
||||||
|
group and only `store/data` is writable by the web/scheduler user:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
sudo chown -R root:root /var/www/netbox-plugin-store
|
sudo chown -R root:root /var/www/netbox-plugin-store
|
||||||
@@ -79,13 +122,14 @@ sudo install -d -o www-data -g www-data -m 0750 \
|
|||||||
sudo chown -R www-data:www-data /var/www/netbox-plugin-store/store/data
|
sudo chown -R www-data:www-data /var/www/netbox-plugin-store/store/data
|
||||||
```
|
```
|
||||||
|
|
||||||
### Apache VirtualHost
|
### Apache virtual host
|
||||||
|
|
||||||
Der VirtualHost zeigt direkt auf `store/public`. `AllowOverride All` ist erforderlich, damit die mitgelieferte `.htaccess` das Front-Controller-Rewrite aktivieren kann:
|
The virtual host points directly to `store/public`. `AllowOverride All` is
|
||||||
|
required so the bundled `.htaccess` can enable the front-controller rewrite:
|
||||||
|
|
||||||
```apache
|
```apache
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerName plugins.example.internal
|
ServerName plugins.example.com
|
||||||
DocumentRoot /var/www/netbox-plugin-store/store/public
|
DocumentRoot /var/www/netbox-plugin-store/store/public
|
||||||
|
|
||||||
<Directory /var/www/netbox-plugin-store/store/public>
|
<Directory /var/www/netbox-plugin-store/store/public>
|
||||||
@@ -99,7 +143,8 @@ Der VirtualHost zeigt direkt auf `store/public`. `AllowOverride All` ist erforde
|
|||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
```
|
```
|
||||||
|
|
||||||
Die Konfiguration wird zum Beispiel als `/etc/apache2/sites-available/netbox-plugin-store.conf` gespeichert und aktiviert:
|
Save it, for example, as `/etc/apache2/sites-available/netbox-plugin-store.conf`
|
||||||
|
and enable it:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
sudo a2ensite netbox-plugin-store.conf
|
sudo a2ensite netbox-plugin-store.conf
|
||||||
@@ -107,11 +152,14 @@ sudo apache2ctl configtest
|
|||||||
sudo systemctl reload apache2
|
sudo systemctl reload apache2
|
||||||
```
|
```
|
||||||
|
|
||||||
Für Produktion wird derselbe DocumentRoot in einem TLS-VirtualHost verwendet. Weder das Repository-Wurzelverzeichnis noch `store/` selbst dürfen als DocumentRoot dienen, da dort Konfiguration und Laufzeitdaten liegen.
|
For production, use the same document root in a TLS virtual host. Neither the
|
||||||
|
repository root nor `store/` itself may serve as document root, since they hold
|
||||||
|
configuration and runtime data.
|
||||||
|
|
||||||
### Initialisierung und erster Import
|
### Initialisation and first import
|
||||||
|
|
||||||
CLI und Apache müssen den JSON-Zustand mit derselben UID verwalten. Deshalb laufen Bootstrap und Sync als Apache-Benutzer:
|
CLI and Apache must manage the JSON state with the same UID, so bootstrap and
|
||||||
|
sync run as the Apache user:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
cd /var/www/netbox-plugin-store/store
|
cd /var/www/netbox-plugin-store/store
|
||||||
@@ -119,11 +167,14 @@ sudo -u www-data php bin/console bootstrap
|
|||||||
sudo -u www-data php bin/console sync
|
sudo -u www-data php bin/console sync
|
||||||
```
|
```
|
||||||
|
|
||||||
Danach sind Website und `/healthz` erreichbar. Die Admin-Anmeldung liegt unter `/admin`. Importierte Kandidaten bleiben bis zur manuellen Prüfung und Freigabe unsichtbar für den öffentlichen API-Katalog.
|
The website and `/healthz` are then reachable. The admin login is at `/admin`.
|
||||||
|
Imported candidates stay hidden from the public API catalogue until they are
|
||||||
|
reviewed and approved manually.
|
||||||
|
|
||||||
### Regelmäßige Synchronisierung
|
### Regular synchronisation
|
||||||
|
|
||||||
Bevorzugt läuft der Watch-Modus als eigener systemd-Dienst. Beispiel für `/etc/systemd/system/netbox-plugin-store-sync.service`:
|
The preferred way is watch mode as a separate systemd service. Example
|
||||||
|
`/etc/systemd/system/netbox-plugin-store-sync.service`:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -156,80 +207,118 @@ sudo systemctl enable --now netbox-plugin-store-sync.service
|
|||||||
sudo systemctl status netbox-plugin-store-sync.service
|
sudo systemctl status netbox-plugin-store-sync.service
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternativ kann `www-data` den einmaligen Befehl per Cron aufrufen. Dazu `sudo crontab -u www-data -e` öffnen und die folgende Zeile eintragen. `flock` verhindert überlappende Läufe:
|
Alternatively, `www-data` can run the one-off command from cron. Open
|
||||||
|
`sudo crontab -u www-data -e` and add the following line; `flock` prevents
|
||||||
|
overlapping runs:
|
||||||
|
|
||||||
```cron
|
```cron
|
||||||
*/15 * * * * /usr/bin/flock -n /var/www/netbox-plugin-store/store/data/sync-cron.lock /bin/sh -c 'cd /var/www/netbox-plugin-store/store && /usr/bin/php bin/console sync' 2>&1 | /usr/bin/logger -t netbox-plugin-store-sync
|
*/15 * * * * /usr/bin/flock -n /var/www/netbox-plugin-store/store/data/sync-cron.lock /bin/sh -c 'cd /var/www/netbox-plugin-store/store && /usr/bin/php bin/console sync' 2>&1 | /usr/bin/logger -t netbox-plugin-store-sync
|
||||||
```
|
```
|
||||||
|
|
||||||
Der Store selbst weist zusätzlich jeden parallelen Sync-Lauf ab. Pro Lauf gelten standardmäßig 900 Sekunden, 2.500 HTTP-Requests, 1 GiB Downloadvolumen, 2.000 Repositories und 1.000 Releases als gemeinsame Obergrenzen. Diese Werte lassen sich mit `STORE_SYNC_MAX_SECONDS`, `STORE_SYNC_MAX_REQUESTS`, `STORE_SYNC_MAX_BYTES`, `STORE_SYNC_MAX_REPOSITORIES` und `STORE_SYNC_MAX_RELEASES` in `store/.env` an die eigene Instanz anpassen.
|
The store itself also rejects any concurrent sync run. By default, each run is
|
||||||
|
limited to 900 seconds, 2,500 HTTP requests, 1 GiB of downloads, 2,000
|
||||||
|
repositories and 1,000 releases in total. Adjust these with
|
||||||
|
`STORE_SYNC_MAX_SECONDS`, `STORE_SYNC_MAX_REQUESTS`, `STORE_SYNC_MAX_BYTES`,
|
||||||
|
`STORE_SYNC_MAX_REPOSITORIES` and `STORE_SYNC_MAX_RELEASES` in `store/.env`.
|
||||||
|
|
||||||
### Native MariaDB-Option
|
### MariaDB option
|
||||||
|
|
||||||
JSON und MariaDB sind alternative Zustands-Speicher. Ein Wechsel des Treibers migriert bestehende Freigaben nicht automatisch. Nach dem Anlegen einer eigenen Datenbank und eines eingeschränkten Datenbankbenutzers werden diese Werte in `store/.env` gesetzt:
|
JSON and MariaDB are alternative state stores. Switching the driver does not
|
||||||
|
migrate existing approvals automatically. After creating a dedicated database
|
||||||
|
and a restricted database user, set these values in `store/.env`:
|
||||||
|
|
||||||
```dotenv
|
```dotenv
|
||||||
STORE_DB_DRIVER=mariadb
|
STORE_DB_DRIVER=mariadb
|
||||||
STORE_MARIADB_DSN=mysql:host=127.0.0.1;port=3306;dbname=netbox_store;charset=utf8mb4
|
STORE_MARIADB_DSN=mysql:host=127.0.0.1;port=3306;dbname=netbox_store;charset=utf8mb4
|
||||||
STORE_MARIADB_USER=netbox_store
|
STORE_MARIADB_USER=netbox_store
|
||||||
STORE_MARIADB_PASSWORD=EIN-EIGENES-ZUFÄLLIGES-PASSWORT
|
STORE_MARIADB_PASSWORD=A-RANDOM-PASSWORD
|
||||||
```
|
```
|
||||||
|
|
||||||
Die erforderliche Tabelle wird bei Bootstrap, Sync oder dem ersten Web-Aufruf angelegt. Das Datenbankkonto benötigt dafür Rechte auf genau diese Datenbank. `STORE_JSON_PATH` wird im MariaDB-Modus nicht verwendet.
|
The required table is created on bootstrap, sync or the first web request; the
|
||||||
|
database account needs privileges on exactly this database.
|
||||||
|
`STORE_JSON_PATH` is not used in MariaDB mode.
|
||||||
|
|
||||||
## Optional: Docker Compose
|
## Installation of the store (Docker Compose)
|
||||||
|
|
||||||
Alternativ kann derselbe Apache/PHP-Store in einem Container laufen. Der Standard-Stack bindet seinen Port absichtlich nur an localhost und verwendet ein benanntes JSON-Volume:
|
Alternatively, the same Apache/PHP store can run in a container. The default
|
||||||
|
stack binds its port to localhost only and uses a named JSON volume:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
docker compose build store
|
docker compose build store
|
||||||
```
|
```
|
||||||
|
|
||||||
Unter Windows kann statt `cp` der Befehl `copy .env.example .env` verwendet werden. Vor dem Start werden in der Root-`.env` eigene Admin-Zugangsdaten gesetzt. Ohne vollständige Admin-Konfiguration bleibt die Anmeldung deaktiviert; es gibt kein Standardpasswort.
|
On Windows, use `copy .env.example .env` instead of `cp`. Set your own admin
|
||||||
|
credentials in the root `.env` before starting. Without a complete admin
|
||||||
|
configuration, login stays disabled; there is no default password.
|
||||||
|
|
||||||
Hash und Session-Geheimnis lassen sich mit dem gebauten Image erzeugen:
|
Generate the hash and session secret with the built image:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
docker compose run --rm --no-deps -e STORE_SCHEDULER_ENABLED=false store php bin/console hash-password 'EIN-LANGES-ZUFÄLLIGES-PASSWORT'
|
docker compose run --rm --no-deps -e STORE_SCHEDULER_ENABLED=false store php bin/console hash-password 'A-LONG-RANDOM-PASSWORD'
|
||||||
docker compose run --rm --no-deps -e STORE_SCHEDULER_ENABLED=false store php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'
|
docker compose run --rm --no-deps -e STORE_SCHEDULER_ENABLED=false store php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'
|
||||||
```
|
```
|
||||||
|
|
||||||
Danach:
|
Then:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
Der im Container aktivierte Scheduler führt den ersten Import unmittelbar aus. Mit `docker compose logs -f store` lässt sich der Lauf verfolgen. Für einen ausschließlich manuellen Sync wird vorher `STORE_SCHEDULER_ENABLED=false` gesetzt und anschließend `docker compose exec store php bin/console sync` aufgerufen.
|
The scheduler in the container runs the first import immediately; follow it
|
||||||
|
with `docker compose logs -f store`. For manual sync only, set
|
||||||
|
`STORE_SCHEDULER_ENABLED=false` first and then run
|
||||||
|
`docker compose exec store php bin/console sync`.
|
||||||
|
|
||||||
Der Store ist standardmäßig auf `http://127.0.0.1:8080` erreichbar. Für MariaDB werden in `.env` mindestens `MARIADB_PASSWORD` und `MARIADB_ROOT_PASSWORD` auf unterschiedliche, zufällige Werte gesetzt und das Overlay zugeschaltet:
|
The store is available at `http://127.0.0.1:8080` by default. For MariaDB, set
|
||||||
|
at least `MARIADB_PASSWORD` and `MARIADB_ROOT_PASSWORD` to different random
|
||||||
|
values in `.env` and enable the overlay:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
docker compose -f compose.yaml -f compose.mariadb.yaml up -d --build
|
docker compose -f compose.yaml -f compose.mariadb.yaml up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
MariaDB erhält keinen Host-Port und ist nur im internen Compose-Netz erreichbar. Der Store wartet auf den Datenbank-Healthcheck.
|
MariaDB gets no host port and is only reachable inside the Compose network. The
|
||||||
|
store waits for the database health check.
|
||||||
|
|
||||||
## Synchronisierung und Freigabe
|
## Usage
|
||||||
|
|
||||||
Der voreingestellte Forgejo-Import liest Repositories von `https://git.mrblake.cc`. GitHub ist bereits als zweiter Provider implementiert und kann im Admin-Bereich über dieselbe Quellenverwaltung hinzugefügt werden.
|
### Synchronisation and approval
|
||||||
|
|
||||||
Mit einem Token lassen sich auch Metadaten und README privater GitHub-Repositories synchronisieren. Private Artefakte bleiben in API v1 bewusst nicht installierbar, weil der Host-Agent keine Provider-Zugangsdaten erhält. Öffentliche Projekte benötigen kein Release: Fehlt ein Wheel-Release, erzeugt der Store einen separat freizugebenden Source-Kandidaten für den exakten aktuellen Commit.
|
The preset Forgejo import reads repositories from the configured default source
|
||||||
|
(`https://git.mrblake.cc`). GitHub is implemented as a second provider and can
|
||||||
|
be added in the admin area through the same source management.
|
||||||
|
|
||||||
Der normale Ablauf ist:
|
With a token, metadata and READMEs of private GitHub repositories can be synced
|
||||||
|
too. Private artefacts are intentionally not installable in API v1, because the
|
||||||
|
host agent receives no provider credentials. Public projects do not need a
|
||||||
|
release: if a wheel release is missing, the store creates a source candidate for
|
||||||
|
the exact current commit, which is approved separately.
|
||||||
|
|
||||||
1. Der Scheduler oder `php bin/console sync` liest Repository-Metadaten, Manifest/Packaging-Konfiguration, Releases und die README eines festen Commit-SHA ein.
|
The normal flow is:
|
||||||
2. Neue oder in installrelevanten Feldern geänderte Datensätze erhalten den Status `pending`.
|
|
||||||
3. Ein Administrator prüft Quelle, Paket-/Importname, NetBox-Kompatibilität, Artifact-URL, Größe und SHA-256.
|
|
||||||
4. Quelle, Plugin und Release werden getrennt freigegeben. Eine Freigabe ist keine automatische Folge der Synchronisierung.
|
|
||||||
5. Nur aktive, vollständige und freigegebene Datensätze erscheinen unter `/api/v1/plugins/`.
|
|
||||||
|
|
||||||
Die Detailseite wird aus der gespeicherten README erzeugt. Relative Links und Bilder werden auf den synchronisierten Commit aufgelöst; HTML wird vor der Ausgabe bereinigt. Verändert sich ein Artifact oder ein installrelevantes Metadatum, muss das Release erneut geprüft werden.
|
1. The scheduler or `php bin/console sync` reads repository metadata,
|
||||||
|
manifest/packaging configuration, releases and the README of a fixed commit
|
||||||
|
SHA.
|
||||||
|
2. New records, or records whose install-relevant fields changed, get the
|
||||||
|
status `pending`.
|
||||||
|
3. An administrator reviews source, package/import name, NetBox
|
||||||
|
compatibility, artefact URL, size and SHA-256.
|
||||||
|
4. Source, plugin and release are approved separately. Approval is never an
|
||||||
|
automatic result of a sync.
|
||||||
|
5. Only active, complete and approved records appear under `/api/v1/plugins/`.
|
||||||
|
|
||||||
## NetBox-Host installieren
|
The detail page is generated from the stored README. Relative links and images
|
||||||
|
are resolved against the synced commit; HTML is sanitised before output. If an
|
||||||
|
artefact or install-relevant metadata changes, the release must be reviewed
|
||||||
|
again.
|
||||||
|
|
||||||
Der empfohlene Weg ist der interaktive Root-Installer. Er installiert das NetBox-Plugin und den separaten Host-Agent, erkennt Dienstkonto sowie NetBox-Version, richtet Requirements und systemd ein und verwaltet einen klar markierten Block in `configuration.py`.
|
### Installing on the NetBox host
|
||||||
|
|
||||||
|
The recommended way is the interactive root installer. It installs the NetBox
|
||||||
|
plugin and the separate host agent, detects the service account and NetBox
|
||||||
|
version, sets up requirements and systemd and manages a clearly marked block in
|
||||||
|
`configuration.py`.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
curl -fsSLo /tmp/netbox-store-install.sh \
|
curl -fsSLo /tmp/netbox-store-install.sh \
|
||||||
@@ -238,18 +327,28 @@ less /tmp/netbox-store-install.sh
|
|||||||
sudo bash /tmp/netbox-store-install.sh
|
sudo bash /tmp/netbox-store-install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Das Script bietet zwei Modi:
|
The script offers two modes:
|
||||||
|
|
||||||
- **Sicherer Testmodus:** Lifecycle-Aufträge bleiben Dry-Runs und verändern keine Plugins.
|
- **Safe test mode:** life-cycle jobs remain dry runs and change no plugins.
|
||||||
- **Produktionsmodus:** Echte Änderungen laufen ausschließlich über den Host-Agent. Zusätzlich zur Zusammenfassung muss der Betreiber exakt `ECHT INSTALLIEREN` bestätigen.
|
- **Production mode:** real changes run exclusively through the host agent. In
|
||||||
|
addition to the summary, the operator must confirm by typing exactly
|
||||||
|
`ECHT INSTALLIEREN`.
|
||||||
|
|
||||||
Alle während eines Laufs geladenen Komponenten werden auf denselben angezeigten Commit gepinnt. Vorhandene Dateien werden unter `/var/backups/netbox-plugin-store/<Zeitstempel>/` gesichert. Das Script kann für Updates erneut ausgeführt werden: Es ersetzt nur seinen markierten Konfigurationsblock und seine eigenen Requirement-Einträge.
|
All components loaded during a run are pinned to the same displayed commit.
|
||||||
|
Existing files are backed up under
|
||||||
|
`/var/backups/netbox-plugin-store/<timestamp>/`. The script can be re-run for
|
||||||
|
updates: it only replaces its own marked configuration block and its own
|
||||||
|
requirement entries.
|
||||||
|
|
||||||
Nach der Einrichtung prüft der Installer den Agent-Socket als NetBox-Dienstkonto. Eine echte Plugin-Installation muss im Audit `Dry-Run: Nein` zeigen. Neu installierte Plugins bleiben zunächst deaktiviert und werden anschließend über eine separate Aktion aktiviert.
|
After setup, the installer checks the agent socket as the NetBox service
|
||||||
|
account. A real plugin installation must show `Dry-Run: Nein` (dry run: no) in
|
||||||
|
the audit. Newly installed plugins stay disabled at first and are enabled with
|
||||||
|
a separate action.
|
||||||
|
|
||||||
### Manuelle Plugin-Installation
|
### Manual plugin installation
|
||||||
|
|
||||||
Das Plugin unter `netbox_plugin/` ist auf NetBox 4.6.5–4.6.8 begrenzt. Zuerst wird ein Wheel gebaut und in die NetBox-Virtualenv installiert:
|
The plugin in `netbox_plugin/` is limited to NetBox 4.6.5–4.6.8. Build a wheel
|
||||||
|
and install it into the NetBox virtualenv:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
cd netbox_plugin
|
cd netbox_plugin
|
||||||
@@ -257,7 +356,8 @@ python -m build
|
|||||||
/opt/netbox/venv/bin/pip install dist/netbox_plugin_store-0.1.3-py3-none-any.whl
|
/opt/netbox/venv/bin/pip install dist/netbox_plugin_store-0.1.3-py3-none-any.whl
|
||||||
```
|
```
|
||||||
|
|
||||||
Das Paket muss außerdem in `/opt/netbox/local_requirements.txt` festgehalten werden. In `configuration.py` wird es zunächst sicher im Dry-run-Modus eingerichtet:
|
Also record the package in `/opt/netbox/local_requirements.txt`. In
|
||||||
|
`configuration.py`, set it up in safe dry-run mode first:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
PLUGINS = [
|
PLUGINS = [
|
||||||
@@ -266,29 +366,39 @@ PLUGINS = [
|
|||||||
|
|
||||||
PLUGINS_CONFIG = {
|
PLUGINS_CONFIG = {
|
||||||
"netbox_plugin_store": {
|
"netbox_plugin_store": {
|
||||||
"store_url": "https://plugins.example.internal",
|
"store_url": "https://plugins.example.com",
|
||||||
"allowed_store_urls": ["https://plugins.example.internal"],
|
"allowed_store_urls": ["https://plugins.example.com"],
|
||||||
"allowed_artifact_urls": [
|
"allowed_artifact_urls": [
|
||||||
"https://plugins.example.internal",
|
"https://plugins.example.com",
|
||||||
"https://git.mrblake.cc",
|
"https://git.example.com",
|
||||||
],
|
],
|
||||||
"execution_mode": "dry_run",
|
"execution_mode": "dry_run",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Danach wird der übliche NetBox-Upgrade-Ablauf mit Migration, `collectstatic` und Neustart von Web- und RQ-Dienst ausgeführt. Details und alle Einstellungen stehen in [`netbox_plugin/README.md`](netbox_plugin/README.md).
|
Then run the usual NetBox upgrade steps: migration, `collectstatic` and a
|
||||||
|
restart of the web and RQ services. Details and all settings are in
|
||||||
|
[`netbox_plugin/README.md`](netbox_plugin/README.md).
|
||||||
|
|
||||||
### Manuelle Produktionseinrichtung: Host-Agent
|
### Manual production setup: host agent
|
||||||
|
|
||||||
Für echte Installationen ist `execution_mode = "agent"` die vorgesehene Trennung: Der NetBox-Webprozess bleibt unprivilegiert und sendet einen kleinen Auftrag über den Unix-Socket `/run/netbox-store-agent/agent.sock`. Der Agent ruft Plugin und Release erneut aus dem Store ab, vergleicht die Freigabemarkierung und prüft Wheel, Dateigröße und SHA-256 vor jeder Änderung.
|
For real installations, `execution_mode = "agent"` provides the intended
|
||||||
|
separation: the NetBox web process stays unprivileged and sends a small job
|
||||||
|
over the Unix socket `/run/netbox-store-agent/agent.sock`. The agent fetches
|
||||||
|
plugin and release from the store again, compares the approval marker and
|
||||||
|
verifies wheel, file size and SHA-256 before every change.
|
||||||
|
|
||||||
Kurzablauf auf dem Linux-NetBox-Host:
|
On the Linux NetBox host:
|
||||||
|
|
||||||
1. Das Paket aus `host_agent/` in eine administrative Python-Umgebung installieren.
|
1. Install the package from `host_agent/` into an administrative Python
|
||||||
2. `host_agent/examples/agent.toml` nach `/etc/netbox-store-agent/agent.toml` kopieren, alle Hosts, Pfade, UIDs/GIDs und die NetBox-Version anpassen und die Datei root-owned mit Modus `0600` schützen.
|
environment.
|
||||||
3. Die beiden Dateien aus `host_agent/systemd/` nach `/etc/systemd/system/` kopieren. Insbesondere `SocketGroup` muss zur NetBox-Servicegruppe passen.
|
2. Copy `host_agent/examples/agent.toml` to `/etc/netbox-store-agent/agent.toml`,
|
||||||
4. Die vom Agent verwaltete Plugin-Liste einmalig in `configuration.py` einbinden:
|
adjust all hosts, paths, UIDs/GIDs and the NetBox version, and protect the
|
||||||
|
file as root-owned with mode `0600`.
|
||||||
|
3. Copy both files from `host_agent/systemd/` to `/etc/systemd/system/`. In
|
||||||
|
particular, `SocketGroup` must match the NetBox service group.
|
||||||
|
4. Include the agent-managed plugin list in `configuration.py` once:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from netbox.store_plugins import STORE_PLUGINS
|
from netbox.store_plugins import STORE_PLUGINS
|
||||||
@@ -296,7 +406,7 @@ Kurzablauf auf dem Linux-NetBox-Host:
|
|||||||
PLUGINS += STORE_PLUGINS
|
PLUGINS += STORE_PLUGINS
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Socket aktivieren und zunächst im voreingestellten Dry-run-Modus testen:
|
5. Enable the socket and test in the default dry-run mode first:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
@@ -304,9 +414,10 @@ Kurzablauf auf dem Linux-NetBox-Host:
|
|||||||
netbox-store-agent capabilities
|
netbox-store-agent capabilities
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Erst nach erfolgreichen Katalog- und Lifecycle-Tests `dry_run = false` in der root-geschützten Agent-Konfiguration setzen und den Dienst neu starten.
|
6. Only after successful catalogue and life-cycle tests, set `dry_run = false`
|
||||||
|
in the root-protected agent configuration and restart the service.
|
||||||
|
|
||||||
Die NetBox-Konfiguration wird dann ergänzt:
|
Then extend the NetBox configuration:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
PLUGINS_CONFIG["netbox_plugin_store"].update({
|
PLUGINS_CONFIG["netbox_plugin_store"].update({
|
||||||
@@ -316,11 +427,15 @@ PLUGINS_CONFIG["netbox_plugin_store"].update({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Der Agent installiert ausschließlich freigegebene, unveränderliche Artefakte. Source-Archive werden commitgebunden geprüft, offline lokal in ein Wheel gebaut und als gehashte Datei unter `/opt/netbox/.netbox-store-wheels` persistiert. Abhängigkeiten und Build-Backends müssen bereits durch den Betreiber bereitgestellt sein. Vollständige Sicherheits- und Recovery-Hinweise stehen in [`host_agent/README.md`](host_agent/README.md).
|
The agent installs only approved, immutable artefacts. Source archives are
|
||||||
|
verified against their commit, built into a wheel locally and offline, and
|
||||||
|
persisted as a hashed file under `/opt/netbox/.netbox-store-wheels`.
|
||||||
|
Dependencies and build back-ends must already be provided by the operator. Full
|
||||||
|
security and recovery notes are in [`host_agent/README.md`](host_agent/README.md).
|
||||||
|
|
||||||
## API v1
|
### API v1
|
||||||
|
|
||||||
Der öffentliche, nur freigegebene Katalog stellt diese Endpunkte bereit:
|
The public, approved-only catalogue provides these endpoints:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
GET /api/v1/plugins/
|
GET /api/v1/plugins/
|
||||||
@@ -328,11 +443,17 @@ GET /api/v1/plugins/{slug}/
|
|||||||
GET /api/v1/plugins/{slug}/releases/{version}/
|
GET /api/v1/plugins/{slug}/releases/{version}/
|
||||||
```
|
```
|
||||||
|
|
||||||
Ein Plugin enthält unter anderem `package_name`, `import_name`, `min_netbox_version`, `max_netbox_version` und `releases`. Ein installierbares Release enthält `download_url`, Artifact-`sha256`, `artifact_size`, `immutable` und die opake Freigabemarkierung `approved_payload_sha256`. Der genaue Datenfluss und die Vertrauensgrenzen sind in [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) beschrieben.
|
A plugin contains, among others, `package_name`, `import_name`,
|
||||||
|
`min_netbox_version`, `max_netbox_version` and `releases`. An installable
|
||||||
|
release contains `download_url`, artefact `sha256`, `artifact_size`,
|
||||||
|
`immutable` and the opaque approval marker `approved_payload_sha256`. The data
|
||||||
|
flow and trust boundaries are described in
|
||||||
|
[`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md).
|
||||||
|
|
||||||
## Lokale Prüfungen
|
## Development and tests
|
||||||
|
|
||||||
Die Komponenten bringen getrennte Prüfungen mit; sie können ohne produktive NetBox- oder Host-Änderungen ausgeführt werden:
|
Each component has its own checks; they run without touching a production
|
||||||
|
NetBox or host:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
cd store && composer install && composer test
|
cd store && composer install && composer test
|
||||||
|
|||||||
Reference in new issue
Block a user