Skip to main content

CLI Proxmox pour la gestion de labs étudiants

Project description

labomatics

CLI Python pour déployer automatiquement des environnements de lab réseau sur un cluster Proxmox à partir d'un CSV d'étudiants.

Pour chaque étudiant, labomatics provisionne : un pool Proxmox, un VNet VXLAN, une VM OpenWrt (routeur), un compte utilisateur avec ACL, et un jeu de credentials.

pip install labomatics
labomatics init       # crée /etc/labomatics/ avec les configs par défaut
labomatics apply      # synchronise Proxmox avec le CSV

Fonctionnalités

  • Déploiement piloté par CSV — ajouter un étudiant dans students.csv suffit
  • Allocation IP dynamique — WAN et VXLAN lus depuis Proxmox, sans fichier d'état local
  • Flavors — profils de ressources (CPU/RAM/disk) assignés par étudiant
  • Quotas natifs Proxmox — limits sur les pools (max_cpu/ram/disk), 403 à la surcharge
  • Daemon de quota (labomatics-quotad) — surveille et stoppe la VM la plus gourmande si dépassement
  • Build de template — pipeline Packer → provisioning SSH/guest-agent → conversion template
  • Isolation — chaque étudiant est cantonné à son pool et son VNet VXLAN dédié

Installation

pip install labomatics

Ou depuis les sources :

git clone https://github.com/esgilabs/labomatics-cli
cd labomatics-cli
pip install -e ".[dev]"

Démarrage rapide

1. Prérequis Proxmox

  • Proxmox VE 8+ avec SDN activé
  • Zone VXLAN SDN créée (ex. esgilab)
  • Stockage partagé entre tous les nœuds (Ceph / NFS / ZFS répliqué)
  • Token API Proxmox avec les droits nécessaires (Administrator sur /)
  • Template OpenWrt sur le stockage partagé

2. Initialisation

sudo labomatics init
# Crée /etc/labomatics/{infra.yaml, .env, students.csv}

3. Configuration

# /etc/labomatics/.env
PROXMOX_HOST=192.168.1.100
PROXMOX_TOKEN_ID=root@pam!labomatics
PROXMOX_TOKEN_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# /etc/labomatics/infra.yaml
version: "v1"
openwrt:
  vmid_start: 10000
  template_vmid: 90200
  storage: zfs-store
  wan_bridge: vmbr0
  network:
    zone_name: esgilab
    wan_pool:
      network: 172.16.0.0/24
      gateway: 172.16.0.254
      exclude: ["172.16.0.1-172.16.0.10"]
    vxlan_pool:
      network: 10.100.0.0/12
      exclude: []
flavors:
  CO1: {cpu: 4, ram: 8192, disk: 40}
  CO2: {cpu: 8, ram: 16384, disk: 80}

4. Étudiants

# /etc/labomatics/students.csv
id,nom,prenom,flavor
18,jdupont,Jean,CO1
240,mkorniev,Mikhail,CO2

L'id est stable et sert de clé pour le VMID et le tag VXLAN. Ne jamais le réutiliser.

5. Déployer

labomatics diff     # aperçu sans modification
labomatics apply    # déploiement avec confirmation

Commandes CLI

Commande Description
apply [--yes] Synchronise Proxmox avec le CSV
diff Aperçu des changements (lecture seule)
pools Liste les pools gérés
zones Liste les zones SDN
vnets [--zone] Liste les VNets SDN
vms [--pool] Liste les VMs des pools gérés
find <query> Recherche par IP WAN, VNet ou nom
credentials Affiche les credentials générés
ips État des pools IP avec % d'utilisation
status Ressources CPU/RAM/disk par étudiant vs flavor
recreate <nom> [--yes] Recrée la VM OpenWrt d'un étudiant
build-template [nom] Build template via Packer + provisioning
init [--dir] Initialise la configuration

Daemon de quota

labomatics-quotad surveille les ressources des pools étudiants et arrête automatiquement la VM la plus gourmande en RAM si un quota est dépassé. La VM OpenWrt n'est jamais arrêtée.

# Installation systemd
cp systemd/labomatics-quotad.service /etc/systemd/system/
systemctl enable --now labomatics-quotad

Build de template

# Construire toutes les templates définies dans infra.yaml
labomatics build-template

# Construire une template spécifique
labomatics build-template ubuntu-24.04

Pipeline : suppression de l'existante → Packer build → provisioning SSH/guest-agent → shutdown → suppression NICs → conversion template Proxmox.


Structure du projet

labomatics-cli/
├── labomatics/               # Package Python
│   ├── commands/             # Sous-commandes CLI
│   ├── proxmox/              # Couche API Proxmox
│   ├── daemon/               # labomatics-quotad
│   └── templates/            # Fichiers de config exemple
├── docs/
│   ├── admin/                # Documentation administrateur
│   └── openwrt/              # Documentation utilisateur final
├── scripts/
│   └── build-openwrt-vm-template.sh
├── systemd/
│   └── labomatics-quotad.service
├── infra.yaml                # Config de l'infra (exemple)
├── students.csv              # CSV étudiants (exemple)
└── pyproject.toml

Documentation

  • docs/admin/ — installation, configuration, CLI (administrateurs Proxmox)
  • docs/openwrt/ — réseau, DHCP, NAT, firewall (étudiants)

Licence

MIT — voir LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labomatics-0.1.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

labomatics-0.1.0-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file labomatics-0.1.0.tar.gz.

File metadata

  • Download URL: labomatics-0.1.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for labomatics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10b67806612719ab3fb7fc1e7d9a7bf9c7c5a60b9a42eca44900a0cd511acf4e
MD5 931ad0eadb5dcf848f034c9cf8cba339
BLAKE2b-256 2d5430f9a26cd82a76811d513334b1e9d800273e98238af8d02cba431a987eb5

See more details on using hashes here.

File details

Details for the file labomatics-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: labomatics-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for labomatics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 528bafabd52b76032852ad3b535334cf4f705bb39c6ab81a43840f08724b3b3d
MD5 486623393e9a0ce9c19dd7e13c2d9516
BLAKE2b-256 d9590c57bf23bc8f45e2174ce34142a1bce81e7b7755195e6a00eedfee5eb5b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page