📦 Vagrant + VirtualBox + LFCS Lab (Fedora)
1. Objectif
Mettre en place un environnement de lab LFCS avec Vagrant et VirtualBox : 2 machines Ubuntu reliées par un réseau privé + NAT.
2. Installation
2.1 Vagrant
sudo dnf install -y vagrant
Vé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. Commandes essentielles
Démarrer les VM
vagrant up
SSH dans une VM
vagrant ssh ubuntu1
vagrant ssh ubuntu2
Éteindre proprement
vagrant halt
Redémarrer
vagrant reload
Suspendre (RAM sauvegardée)
vagrant suspend
Reprendre
vagrant resume
Supprimer complètement
vagrant destroy -f
6. 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
- vagrant halt
- vagrant reload
- vagrant suspend
Non persistant
- vagrant destroy
8. Dossier partagé
HĂ´te Fedora:
~/Documents/github/lfcs/all-courses
VM:
/vagrant
Exemple :
echo "test" > test.txt
cat /vagrant/test.txt
9. Workflow recommandé
# Démarrer
vagrant up
# Travailler
vagrant ssh ubuntu1
# Fin de session
vagrant halt
# Reprendre
vagrant up
10. Résumé
- Vagrant = orchestration des VM
- VirtualBox = hyperviseur
- halt = arrĂŞt propre
- suspend = mise en veille
- destroy = reset complet
- /vagrant = partage hôte ↔ VM