90DaysOfDevOps/2022/Days/Kubernetes/Rancher/Vagrantfile
2022-11-18 14:43:39 +00:00

40 lines
1.4 KiB
Ruby

NUM_WORKER_NODES=2
IP_NW="192.168.169."
IP_START=130
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 :public_network, bridge: "Intel(R) Ethernet Connection (7) I219-V", 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"
end
(1..NUM_WORKER_NODES).each do |i|
config.vm.define "node0#{i}" do |node|
node.vm.hostname = "worker-node0#{i}"
node.vm.network :public_network, bridge: "Intel(R) Ethernet Connection (7) I219-V", ip: IP_NW + "#{IP_START}"
node.vm.provider "virtualbox" do |vb|
vb.memory = 4048
vb.cpus = 1
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
node.vm.provision "shell", path: "scripts/common.sh"
end
end
end