Skip to main content

📩 Vagrant + VirtualBox + LFCS Lab (Fedora)

1. Objectif

Mettre en place un environnement de labEnvironnement LFCS avec :

    Fedora hÎte VirtualBox hyperviseur 2 VM Ubuntu réseaugérées privé entre VM gestion viapar Vagrant + VirtualBox.

    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)VM)

    Vagrant.configure("2") do |config|
    
      config.vm.define "ubuntu1" do |vm1|vm|
      vm1.vm.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|vm|
      vm2.vm.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 Vagrant essentielles

    vagrant up
    #vagrant démarrerhalt
    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
    #vagrant suppression complĂštestatus
    

    5. RéseauCommandes desréseau VM/ debug Vagrant

      NAT → Internet Host-only → communication inter-VM
      ubuntu1:vagrant 192.168.56.101status
      ubuntu2:vagrant 192.168.56.102ssh ubuntu1
      ip a
      
      ping 192.168.56.102

      ---

      6. DossierDEBUG partagé

      —
      HĂŽte:VirtualBox ~/Documents/github/lfcs/all-courses& VM:
      /vagrant
      

      7. PROBLÈMES RENCONTRÉSKernel (IMPORTANT)

      7.6.1 SecureVérifier Bootmodule +kernel MOKVirtualBox

      lsmod | grep vbox

      Si rien n’apparaüt :

      sudo modprobe vboxdrv

      ---

      6.2 Vérifier VirtualBox

      VBoxManage --version
      which VBoxManage
      rpm -qa | grep -i virtualbox
      

      ---

      6.3 ProblĂšme kernel modules (Fedora)akmods)

      ProblÚmeSur :Fedora, VirtualBox /dépend des modules kernel bloqués par Secure Boot.

      SymptĂŽme :

      VirtualBoxsudo neakmods démarre--rebuild pas--force
      ousudo erreursmodprobe kernelvboxdrv
      modules

      SolutionSi problĂšme persiste :

        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 :

        Vagrantsudo doesreboot
        not

        ---

        support

        7. thisDEBUG version— ofInstallation / rĂ©installation VirtualBox

        Réinstallation complÚte

        sudo dnf reinstall -y VirtualBox-server akmod-VirtualBox VirtualBox-kmodsrc

        Ou nettoyage total :

        sudo dnf remove -y VirtualBox-server akmod-VirtualBox VirtualBox-kmodsrc

        Puis :

        sudo dnf install -y VirtualBox

        Cause---

        :

        8. mismatchDEBUG entre— Vagrant et+ provider VirtualBox

        7.x

        Plugins Vagrant

        vagrant plugin list
        vagrant plugin install vagrant-virtualbox2
        

        Réparation plugins

        vagrant plugin repair
        vagrant plugin expunge --reinstall
        vagrant plugin update

        ---

        Solution

        9. :

        DEBUG — libvirt (ancien essai Fedora)

        ProblÚmes rencontrés

        • MettreNo Ă URI jourprovided (Vagrant vers version rĂ©cente (>= 2.4.x)

        7.3 ProblĂšme libvirt (alternative Vagrant provider)

        ProblÚmes rencontrés :

          libvirtd non accessible via socketlibvirt) virtqemud / virtstoraged malsockets synchronisésmanquants VagrantSELinux erreurbloque :ports "NoVNC URI is provided"(5701)

          Cause

          Commandes :

          de diagnostic utilisées
          virsh net-list --all
          virsh domifaddr all-courses_ubuntu1
          virsh domiflist all-courses_ubuntu1
          virsh dumpxml all-courses_ubuntu1
          systemctl status libvirtd
          

          Conclusion

          MigrationLibvirt fonctionne mais est trop complexe sur Fedora vers44 architecturepour libvirtce modulairelab. (virtqemud, virtnetworkd, etc.)

          Conclusion :

          VirtualBox est plus simple et stable pour ce lab LFCS.


          ---

          10. Secure Boot / MOK (Fedora)

          7.4 SELinux bloque VNC (libvirt)ProblĂšme

          ErreurModules :kernel VirtualBox bloqués par Secure Boot

          SELinux

          Solution

          interdit
          rpc-virtqemudEnrÎler surMOK portkey 5701Redémarrer

          Solutionmachine

          testéeValider :dans interface Secure Boot
          sudo semanage portmokutil -a -t vnc_port_t -p tcp 5701list-enrolled

          Note : complexe → abandon libvirt pour VirtualBox dans ce contexte.---


          8.11. Cycle de travail recommandé

          # démarrer
          vagrant up
          
          # travailler
          vagrant ssh ubuntu1
          # arrĂȘter proprement
          vagrant halt
          
          # reprendre
          vagrant up
          

          ---

          9.12. BonnesRésumé pratiquestroubleshooting

          • toujoursvboxdrv utiliserabsent vagrant→ haltmodprobe avantou arrĂȘt machineakmods
          • Ă©viterVBoxManage destroycassĂ© sauf→ resetreinstall completVirtualBox
          • prĂ©fĂ©rerVagrant VirtualBoxincompatible → update Vagrant
          libvirt complexe → abandon dans ce lab MOK obligatoire sur Fedora pourSecure simplicitĂ© LFCS utiliser rĂ©seau host-only pour exercices inter-machinesBoot

          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