mirror of
https://github.com/MichaelCade/90DaysOfDevOps.git
synced 2025-01-07 05:50:32 +07:00
40 lines
1.4 KiB
Ruby
40 lines
1.4 KiB
Ruby
NUM_WORKER_NODES=2
|
|
IP_NW="10.0.0."
|
|
IP_START=10
|
|
|
|
Vagrant.configure("2") do |config|
|
|
config.vm.provision "shell", inline: <<-SHELL
|
|
apt-get update -y
|
|
echo "$IP_NW$((IP_START)) master-node" >> /etc/hosts
|
|
echo "$IP_NW$((IP_START+1)) worker-node01" >> /etc/hosts
|
|
echo "$IP_NW$((IP_START+2)) worker-node02" >> /etc/hosts
|
|
SHELL
|
|
config.vm.box = "bento/ubuntu-21.10"
|
|
config.vm.box_check_update = true
|
|
|
|
config.vm.define "master" do |master|
|
|
master.vm.hostname = "master-node"
|
|
master.vm.network "private_network", ip: IP_NW + "#{IP_START}"
|
|
master.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 4048
|
|
vb.cpus = 2
|
|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
|
end
|
|
master.vm.provision "shell", path: "scripts/common.sh"
|
|
master.vm.provision "shell", path: "scripts/master.sh"
|
|
end
|
|
|
|
(1..NUM_WORKER_NODES).each do |i|
|
|
config.vm.define "node0#{i}" do |node|
|
|
node.vm.hostname = "worker-node0#{i}"
|
|
node.vm.network "private_network", ip: IP_NW + "#{IP_START + i}"
|
|
node.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 2048
|
|
vb.cpus = 1
|
|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
|
end
|
|
node.vm.provision "shell", path: "scripts/common.sh"
|
|
node.vm.provision "shell", path: "scripts/node.sh"
|
|
end
|
|
end
|
|
end |