Vagrant.configure("2") do |config| # Configuration de Debian (première VM) config.vm.define "debian" do |debian| debian.vm.box = "debian/bullseye64" debian.vm.hostname = "debian" debian.vm.network "private_network", ip: "192.168.0.15", virtualbox__intnet: true debian.vm.provider "virtualbox" do |vb| vb.memory = "2048" vb.cpus = 1 vb.gui = true end debian.vm.provision "shell", inline: <<-SHELL apt-get update apt-get upgrade -y apt-get install -y openssh-server systemctl start ssh systemctl enable ssh SHELL end # Configuration de Fedora (contrôleur Ansible) config.vm.define "fedora" do |fedora| fedora.vm.box = "fedora/37-cloud-base" fedora.vm.hostname = "fedora" fedora.vm.network "private_network", ip: "192.168.0.5", virtualbox__intnet: true fedora.vm.provider "virtualbox" do |vb| vb.memory = "2048" vb.cpus = 2 vb.gui = true end fedora.vm.provision "shell", inline: "sleep 30", run: "always" fedora.vm.provision "shell", inline: <<-SHELL dnf update -y dnf install -y ansible openssh-server ansible-core NetworkManager-tui # Configuration du réseau nmcli connection add type ethernet \ con-name "eth1" \ ifname eth1 \ ipv4.method manual \ ipv4.addresses 192.168.0.5/24 \ ipv4.gateway 192.168.0.1 \ connection.autoconnect yes # Activer la connexion nmcli connection up eth1 # Démarrer et activer les services nécessaires systemctl start NetworkManager systemctl enable NetworkManager systemctl restart NetworkManager systemctl start sshd systemctl enable sshd # Vérifier la configuration ip addr show eth1 SHELL end # Configuration d'Arch Linux config.vm.define "arch" do |arch| arch.vm.box = "archlinux/archlinux" arch.vm.hostname = "arch" arch.vm.network "private_network", ip: "192.168.0.10", virtualbox__intnet: true arch.vm.provider "virtualbox" do |vb| vb.memory = "2048" vb.cpus = 1 vb.gui = true end arch.vm.provision "shell", inline: "sleep 30", run: "always" arch.vm.provision "shell", inline: <<-SHELL pacman -Sy --noconfirm pacman -S --noconfirm openssh # Configuration réseau avec systemd-networkd cat > /etc/systemd/network/eth1.network << EOF [Match] Name=eth1 [Network] Address=192.168.0.10/24 Gateway=192.168.0.1 EOF systemctl enable systemd-networkd systemctl start systemd-networkd systemctl enable sshd systemctl start sshd ip link set eth1 down ip link set eth1 up systemctl status systemd-networkd ip addr show eth1 SHELL end end