# -*- mode: ruby -*-
# Cluster kubeadm de recette (Kalypso Sports) : cp1, w1, w2 sur 192.168.56.0/24.
# Usage : vagrant up  (10 à 15 minutes la première fois) puis vagrant ssh cp1
# Prérequis : VirtualBox 7 et Vagrant, environ 7 Go de mémoire libre.
NOEUDS = {
  "cp1" => "192.168.56.10",
  "w1"  => "192.168.56.11",
  "w2"  => "192.168.56.12",
}

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-24.04"
  config.vm.box_check_update = false

  NOEUDS.each do |nom, ip|
    config.vm.define nom do |n|
      n.vm.hostname = nom
      n.vm.network "private_network", ip: ip
      n.vm.provider "virtualbox" do |vb|
        vb.name = "kalypso-#{nom}"
        vb.cpus = 2
        vb.memory = 2048
      end
      # Résolution des noms entre les trois machines
      n.vm.provision "shell", inline: <<-SHELL
        grep -q "cp1" /etc/hosts || cat >> /etc/hosts <<EOH
192.168.56.10 cp1
192.168.56.11 w1
192.168.56.12 w2
EOH
      SHELL
    end
  end
end
