Skip to main content

CLI Proxmox pour la gestion de labs étudiants

Project description

labomatics

PyPI Python Licence: MIT Docs

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/SimonLou-Dev/labomatics
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

  • Admin — installation, configuration, CLI (administrateurs Proxmox)
  • Utilisateur 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.2.0.tar.gz (34.3 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.2.0-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: labomatics-0.2.0.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for labomatics-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bcb75bdfaad95af73004c6afe3984486d2900146bf4834c812192e44dbd4650f
MD5 d9e03c018535f730eca136f247a0689e
BLAKE2b-256 f802c272512db995e5184ab2abb054e71b9f2648921362482aa11738a46424bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for labomatics-0.2.0.tar.gz:

Publisher: release.yml on SimonLou-Dev/labomatics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: labomatics-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 49.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for labomatics-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68e39bf954231b454b20332c8e129ad5f7e6c418c4321de111377f70fd280131
MD5 828e93a0bd8b6be7ca957066db4dedb0
BLAKE2b-256 047e8edf54b9a7cc2841f481b07f3367dc2ac271c4dcc7a32961f79a2bd853fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for labomatics-0.2.0-py3-none-any.whl:

Publisher: release.yml on SimonLou-Dev/labomatics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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