Vagrantfile - examples
Fichier basique juste pour lancer une VM sur VirtualBox
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.define Debian-Lab do |cfg|
cfg.vm.hostname = "Debian-Lab"
cfg.vm.provider "virtualbox" do |v|
v.name= "Debian-Lab"
end #end VB
end #end cfg
end
Installation 3 VM avec Docker sur Virtual Box et Debian 11
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
common = <<-SHELL
sudo apt update 2>&1 >/dev/null
sudo apt install tree git vim curl -y 2>&1 >/dev/null
SHELL
NODES = [
{ :hostname => "docker1", :ip => "192.168.12.78", :cpus => 4, :mem => 2048},
{ :hostname => "docker2", :ip => "192.168.12.79", :cpus => 4 , :mem => 2048},
]
NODES.each do |node|
config.vm.define node[:hostname] do |cfg|
cfg.vm.network "private_network", ip: node[:ip]
cfg.vm.hostname = node[:hostname]
cfg.vm.provider "virtualbox" do |v|
v.name= node[:hostname]
v.memory= node[:mem]
v.cpus= node[:cpus]
end #end VB
#lancement commande SHELL pour le provissionning de la VM
cfg.vm.provision "shell", inline: common
#provissionning avec un script SHEEL
cfg.vm.provision "shell", path:"docker_install.sh"
end #end cfg
end #end nodes
end
Ressources Vagrant:
→ Docs Officielle
→ Stéphane Robert - Apprendre et Maitriser Vagrant