Skip to main content

📩 Vagrant + VirtualBox + LFCS Lab (Fedora)

1. Objectif

Mettre en place un environnement de lab LFCS avec :

  • Fedora hĂŽte
  • VirtualBox hyperviseur
  • 2 VM Ubuntu
  • rĂ©seau privĂ© entre VM
  • gestion via Vagrant

2. Installation

2.1 Vagrant

sudo dnf install -y vagrant
vagrant --version

---

2.2 VirtualBox

sudo dnf install -y VirtualBox
VBoxManage --version

3. 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

4. Commandes essentielles

vagrant up              # démarrer
vagrant ssh ubuntu1     # accĂšs VM
vagrant halt            # arrĂȘt propre
vagrant reload          # redémarrage
vagrant suspend         # pause (RAM sauvegardée)
vagrant resume          # reprise
vagrant destroy -f      # suppression complĂšte

5. Réseau des VM

  • NAT → Internet
  • Host-only → communication inter-VM
ubuntu1: 192.168.56.101
ubuntu2: 192.168.56.102
ping 192.168.56.102

6. Dossier partagé

HĂŽte:
~/Documents/github/lfcs/all-courses

VM:
/vagrant

7. PROBLÈMES RENCONTRÉS (IMPORTANT)

7.1 Secure Boot + MOK (Fedora)

ProblÚme : VirtualBox / modules kernel bloqués par Secure Boot.

SymptĂŽme :

VirtualBox ne démarre pas ou erreurs kernel modules

Solution :

  • EnrĂŽler la clĂ© MOK (Machine Owner Key)
  • RedĂ©marrer et valider dans l’interface MOK

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 :

  • Mettre Ă  jour Vagrant vers version rĂ©cente (>= 2.4.x)

7.3 ProblĂšme libvirt (alternative Vagrant provider)

ProblÚmes rencontrés :

  • libvirtd non accessible via socket
  • virtqemud / virtstoraged mal synchronisĂ©s
  • Vagrant erreur : "No URI is provided"

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.


8. Cycle de travail recommandé

# démarrer
vagrant up

# travailler
vagrant ssh ubuntu1

# arrĂȘter proprement
vagrant halt

# reprendre
vagrant up

9. Bonnes pratiques

  • toujours utiliser vagrant halt avant arrĂȘt machine
  • Ă©viter destroy sauf reset complet
  • prĂ©fĂ©rer VirtualBox sur Fedora pour simplicitĂ© LFCS
  • utiliser rĂ©seau host-only pour exercices inter-machines

10. Résumé

  • Vagrant = orchestration
  • VirtualBox = hyperviseur stable ici
  • MOK = nĂ©cessaire pour modules kernel Fedora
  • libvirt = plus complexe sur Fedora 44
  • environnement LFCS prĂȘt