ansible/playbooks/kubernetes/Vagrantfile

58 lines
1.6 KiB
Ruby

IMAGE_NAME = "bento/ubuntu-22.04"
CONTROL_PLANES = 1
NODES = 0
ansible_groups = {
"control_planes" => [
"control-plane-[1:#{CONTROL_PLANES}]"
],
"nodes" => [
"node-[1:#{NODES}]"
],
"local_dev" => [
"control-plane-[1:#{CONTROL_PLANES}]",
"node-[1:#{NODES}]"
],
}
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
(1..CONTROL_PLANES).each do |i|
config.vm.define "control-plane-#{i}" do |control_plane|
control_plane.vm.box = IMAGE_NAME
control_plane.vm.network "private_network", ip: "192.168.56.#{10 + i}"
control_plane.vm.hostname = "control-plane-#{i}"
control_plane.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yaml"
ansible.groups = ansible_groups
ansible.extra_vars = {
node_ip: "192.168.56.#{10 + i}"
}
end
end
end
(1..NODES).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = IMAGE_NAME
node.vm.network "private_network", ip: "192.168.56.#{20 + i}"
node.vm.hostname = "node-#{i}"
node.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yaml"
ansible.groups = ansible_groups
ansible.extra_vars = {
node_ip: "192.168.56.#{20 + i}",
control_plane_endpoint: "192.168.56.11",
}
end
end
end
end