Update docs and rename domain suffix

The commit message should be:

``` Translate docs to French and update domain examples

Change the example domain from lab.home.arnodo.fr to taila5ad8.ts.net
and convert documentation to French. Remove LXC container configuration
that was not being used. ```

This message captures the key changes: 1. Translation of documentation
to French 2. Update of domain examples throughout the codebase 3.
Removal of unused LXC container configuration

The changes warrant a body since there are multiple related but distinct
changes being made. The message follows the Git commit style guidelines,
using imperative mood and keeping the first line under 50 characters.
This commit is contained in:
darnodo
2025-07-03 19:59:02 +02:00
parent 7cd93ba978
commit 90b49eee17
5 changed files with 363 additions and 540 deletions

290
README.md
View File

@@ -2,70 +2,262 @@
## Description
This repository contains Infrastructure as Code (IaC) configurations for a home lab environment. It uses Terraform to provision virtual machines on Proxmox VE. The initial configuration of the VMs, including the installation and activation of Tailscale, is handled automatically by Cloud-Init.
Ce repository contient l'Infrastructure as Code (IaC) pour un environnement de homelab. Il utilise Terraform pour provisionner des machines virtuelles sur Proxmox VE avec une configuration automatique via Cloud-Init et une intégration Tailscale.
## Usage
## Fonctionnalités
### Prerequisites
- 🚀 **Déploiement automatisé** : Création de VMs via Terraform
- 🔧 **Configuration automatique** : Initialisation via Cloud-Init
- 🌐 **Réseau sécurisé** : Connexion automatique à Tailscale
- 📦 **Templates multiples** : Support Ubuntu, Debian, Alpine, Rocky, CentOS
- 🏷️ **Organisation** : Système de tags pour classifier les VMs
- Terraform installed on your local machine.
- A Proxmox VE instance up and running.
- A Tailscale account and an authentication key.
## Structure du projet
### Proxmox Setup
```
iac-homelab/
├── README.md
├── terraform/
│ └── prod/
│ ├── 01-virtual-machines.tf # Configuration des VMs
│ ├── 02-cloud-init.tf # Configuration Cloud-Init
│ ├── providers.tf # Providers Terraform
│ ├── variables.tf # Variables
│ ├── terraform.tfvars # Configuration personnalisée
│ └── terraform.tfvars.example # Exemple de configuration
└── cloud-init/
└── user-data.yml.tftpl # Template Cloud-Init
```
For Terraform to interact with your Proxmox environment, you must create a dedicated user with specific, limited permissions.
## Prérequis
1. **Create a role (`TerraformProv`) with the necessary privileges:**
```bash
pveum role add TerraformProv -privs "Datastore.Allocate Datastore.AllocateSpace Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Console VM.Migrate VM.Monitor VM.PowerMgmt SDN.Use"
```
- **Terraform** : Version récente installée
- **Proxmox VE** : Serveur opérationnel avec API activée
- **Templates VM** : Templates configurés avec les tags appropriés
- **Tailscale** : Compte avec clé d'authentification
- **SSH** : Clés SSH configurées
2. **Create a dedicated user (`terraform@pve`):**
```bash
pveum user add terraform@pve --password <your_secure_password>
pveum acl modify / -user terraform@pve -role TerraformProv
```
## Configuration initiale
3. **Generate an API token for the user:**
```bash
pveum user token add terraform@pve terraform -expire 0 -privsep 0
```
Securely store the generated token ID and secret, as you will need them to authenticate Terraform.
### 1. Proxmox VE
### Provisioning Infrastructure
Créer un utilisateur dédié avec les permissions nécessaires :
1. **Clone this repository** to your local machine.
```bash
# Créer le rôle
pveum role add TerraformProv -privs "Datastore.Allocate Datastore.AllocateSpace Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Console VM.Migrate VM.Monitor VM.PowerMgmt SDN.Use"
2. **Navigate to the production environment directory:**
```bash
cd iac-homelab/terraform/prod
```
# Créer l'utilisateur
pveum user add terraform@pve --password <mot_de_passe_securise>
pveum acl modify / -user terraform@pve -role TerraformProv
3. **Create a `terraform.tfvars` file.** You can copy the example file to get started:
```bash
cp terraform.tfvars.example terraform.tfvars
```
Edit this file to include your Proxmox API credentials and your Tailscale authentication key.
# Générer le token API
pveum user token add terraform@pve terraform -expire 0 -privsep 0
```
4. **Initialize Terraform:**
```bash
terraform init
```
### 2. Templates VM
5. **Plan and apply the changes:**
```bash
terraform plan
terraform apply
```
Terraform will show you a plan of the resources to be created. If you agree, confirm the apply.
Créer des templates sur Proxmox avec les tags suivants :
### Configuration via Cloud-Init
| OS | Tags requis |
|---|---|
| Ubuntu | `["ubuntu", "template"]` |
| Debian | `["debian", "template"]` |
| Alpine | `["alpine", "template"]` |
| Rocky | `["rocky", "template"]` |
| CentOS | `["centos", "template"]` |
The configuration of virtual machines is handled automatically on the first boot by Cloud-Init. The Terraform configuration injects a script that performs the following actions:
## Déploiement
- Updates and upgrades all system packages.
- Installs the Tailscale agent.
- Connects the new machine to your Tailscale network using the `tailscale_auth_key` you provided.
### 1. Configuration
Once `terraform apply` is complete, your new virtual machines will automatically appear in your Tailscale admin console shortly after they boot up.
```bash
# Cloner le repository
git clone <repository-url>
cd iac-homelab/terraform/prod
# Copier le fichier d'exemple
cp terraform.tfvars.example terraform.tfvars
# Éditer avec vos valeurs
vim terraform.tfvars
```
### 2. Variables importantes
Dans `terraform.tfvars`, configurer :
```hcl
# Proxmox
proxmox_url = "https://pve01.taila5ad8.ts.net:8006"
proxmox_api_token = "terraform@pve!terraform=<token>"
# Tailscale
tailscale_auth_key = "tskey-auth-<votre-cle>"
# SSH
admin_ssh_public_key_path = "~/.ssh/id_rsa.pub"
# VMs
virtual_machines = {
"monitoring" = {
os = "debian"
cores = 2
memory = 4096
disk_gb = 30
ip = "192.168.1.161"
gateway = "192.168.1.254"
tags = ["monitoring"]
}
}
```
### 3. Déploiement
```bash
# Initialisation
terraform init
# Vérification
terraform plan
# Déploiement
terraform apply
```
## Configuration des VMs
### Options de base
```hcl
"nom-vm" = {
os = "debian" # Template à utiliser
cores = 2 # Nombre de cœurs CPU
memory = 4096 # RAM en MB
disk_gb = 30 # Taille du disque en GB
ip = "192.168.1.100" # Adresse IP statique
gateway = "192.168.1.254" # Passerelle réseau
tags = ["web"] # Tags pour l'organisation
}
```
### Options avancées
```hcl
"nom-vm-avancee" = {
# Configuration de base
os = "ubuntu"
cores = 4
memory = 8192
disk_gb = 50
ip = "192.168.1.101"
gateway = "192.168.1.254"
# Options avancées
cpu_type = "host"
datastore = "local-lvm"
network_bridge = "vmbr0"
username = "admin"
# Disques supplémentaires
additional_disks = [
{
interface = "scsi1"
datastore = "local-lvm"
size = 100
}
]
}
```
## Fonctionnalités automatiques
### Cloud-Init
Chaque VM est automatiquement configurée avec :
- Installation des packages de base
- Configuration de l'utilisateur et des clés SSH
- Installation du QEMU Guest Agent
- Configuration du hostname
### Tailscale
Installation et connexion automatique :
- Téléchargement et installation de Tailscale
- Connexion au réseau avec la clé d'authentification
- Configuration du hostname sur le réseau
## Maintenance
### Ajouter une VM
```bash
# 1. Ajouter la configuration dans terraform.tfvars
# 2. Appliquer les changements
terraform apply
```
### Supprimer une VM
```bash
# 1. Retirer la configuration de terraform.tfvars
# 2. Appliquer les changements
terraform apply
```
### Modifier une VM
```bash
# 1. Modifier la configuration dans terraform.tfvars
# 2. Vérifier les changements
terraform plan
# 3. Appliquer
terraform apply
```
## Sécurité
- ✅ Authentification par tokens API
- ✅ Connexion SSH par clés uniquement
- ✅ Réseau sécurisé via Tailscale
- ✅ Isolation des VMs
- ✅ Permissions minimales sur Proxmox
## Dépannage
### Problèmes courants
| Problème | Solution |
|---|---|
| Template non trouvé | Vérifier les tags sur Proxmox |
| IP déjà utilisée | Vérifier les conflits d'adresses |
| Erreur SSH | Vérifier le chemin de la clé publique |
| Tailscale | Vérifier la validité de la clé d'authentification |
### Logs détaillés
```bash
# Logs Terraform détaillés
TF_LOG=DEBUG terraform apply
# État des ressources
terraform show
# Liste des ressources
terraform state list
```
## Ressources recommandées
| Type de service | CPU | RAM | Disque |
|---|---|---|---|
| Monitoring | 2 | 4GB | 30GB |
| Web server | 2 | 2GB | 20GB |
| Database | 4+ | 8GB+ | 50GB+ |
| Kubernetes | 4+ | 4GB+ | 40GB+ |
## Support
- 📚 [Documentation Terraform Proxmox Provider](https://registry.terraform.io/providers/bpg/proxmox/latest/docs)
- 🔧 [Proxmox VE Documentation](https://pve.proxmox.com/wiki/Main_Page)
- 🌐 [Tailscale Documentation](https://tailscale.com/kb/)