📦 Vagrant + VirtualBox + LFCS Lab (Fedora)
1. Objectif
Mettre en place un environnement de lab LFCS avec Vagrant:
- Fedora hôte
2. Installation
2.1 Vagrant
sudo dnf install -y vagrantVérification :
vagrant --version
---
2.2 VirtualBox
sudo dnf install -y VirtualBox
Vérification :
VBoxManage --version
3. Structure du projet
lfcs-lab/
├── Vagrantfile
└── (optionnel) ansible playbooks
4. Vagrantfile (2 VM Ubuntu)
Vagrant.configure("2") do |config|
config.vm.define "ubuntu1" do |vm1|
vm1.vm.box = "ubuntu/focal64"
vm1.vm.hostname = "ubuntu1"
vm1.vm.network "private_network", ip: "192.168.56.101"
vm1.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 2
end
end
config.vm.define "ubuntu2" do |vm2|
vm2.vm.box = "ubuntu/focal64"
vm2.vm.hostname = "ubuntu2"
vm2.vm.network "private_network", ip: "192.168.56.102"
vm2.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 2
end
end
end
5.4. Commandes essentielles
Démarrer les VM
vagrant up SSH# dansdémarrer
une VM
vagrant ssh ubuntu1 vagrant# sshaccès ubuntu2VM
Éteindre proprement
vagrant halt Redémarrer
# arrêt propre
vagrant reload Suspendre# redémarrage
vagrant suspend # pause (RAM sauvegardée)
vagrant suspendReprendre
vagrant resume Supprimer# complètement
reprise
vagrant destroy -f # suppression complète
6.5. Réseau des VM
- NAT → Internet
- Host-only → communication inter-VM
ubuntu1: 192.168.56.101
ubuntu2: 192.168.56.102
Test :
ping 192.168.56.102
7. Gestion des données
Persistant
Non persistant
8.6. Dossier partagé
Hôte Fedora:Hôte:
~/Documents/github/lfcs/all-courses
VM:
/vagrant
7. PROBLÈMES RENCONTRÉS (IMPORTANT)
7.1 Secure Boot + MOK (Fedora)
ExempleProblème : VirtualBox / modules kernel bloqués par Secure Boot.
Symptôme :
echoVirtualBox ne démarre pas ou erreurs kernel modules
Solution :
Résultat : VirtualBox fonctionne avec Secure Boot activé.
7.2 Version Vagrant incompatible VirtualBox
Problème :
Vagrant does not support this version of VirtualBox
Cause :Â mismatch entre Vagrant et VirtualBox 7.x
Solution :
7.3 Problème libvirt (alternative Vagrant provider)
Problèmes rencontrés :
Cause :
Migration Fedora vers architecture libvirt modulaire (virtqemud, virtnetworkd, etc.)
Conclusion :
VirtualBox est plus simple et stable pour ce lab LFCS.
7.4 SELinux bloque VNC (libvirt)
Erreur :
SELinux interdit rpc-virtqemud sur port 5701
Solution testée :
sudo semanage port -a -t vnc_port_t -p tcp 5701
Note : complexe → abandon libvirt pour VirtualBox dans ce contexte.
9.8. WorkflowCycle de travail recommandé
# Démarrerdémarrer
vagrant up
# Travaillertravailler
vagrant ssh ubuntu1
# Finarrêter de sessionproprement
vagrant halt
# Reprendrereprendre
vagrant up
9. Bonnes pratiques
10. Résumé
- Vagrant = orchestration
 des VM - VirtualBox = hyperviseur stable ici
haltMOK =arrêtnécessaireproprepour modules kernel Fedorasuspendlibvirt =miseplusencomplexeveillesur Fedora 44destroyenvironnement=LFCSreset complet