vagrant-lab-swarm/Vagrantfile

51 lines
2.2 KiB
Ruby

# to make sure the nodes are created in order, we
# have to force a --no-parallel execution.
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
require 'ipaddr'
number_of_server_nodes = 5
domain = "dexter.lab"
Vagrant.configure(2) do |config|
config.vm.box = 'debian/bullseye64'
config.vm.provider 'libvirt' do |lv, config|
lv.cpus = 2
lv.cpu_mode = 'host-passthrough'
lv.nested = true
lv.keymap = 'pt'
config.vm.synced_folder '.', '/vagrant', type: 'nfs', nfs_version: '4.2', nfs_udp: false
end
(1..number_of_server_nodes).each do |n|
name = "tt-testing#{n}"
fqdn = "#{name}.#{domain}"
config.vm.define name do |config|
config.vm.provider 'libvirt' do |lv, config|
lv.memory = 2*1024
end
config.vm.hostname = fqdn
config.vm.network :public_network,
:dev => "virbr1",
:bridge => "virbr1",
:mode => "bridge",
:type => "bridge"
config.vm.provision "shell" do |s|
ssh_pub_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGdjG96nkwWE9k7V8YJcog5jnlclWm8aq6QWhChmVoCvvD84W4cm6CuLvLt/cc0kcvyL7nfph0EbtSeH/n6ze1ZoJ38DFLn1iqZfc/oCIwYPA7mO5hd+On8Lgwu5sILerRHjh+YaXH6RWOJyJxbprqIjX7TVLSUm3eBpNSsnotA806bI5rqLmrvXMKM7Uwck+QvHb7PK80ehdysrG8Hi1Z6XC7nhTFV0jHHfUyH5/zdhG2ABkTYb+GMGeAHiEFk9UF5gVB61MFZYsz/MR/v6chemkOtDVFGrOvLGwKsvG/z9fBrgcA7E+H6brZnU9IuNhpQUI9b9YJzNPq7ok2x9odX9TU7uhwYnTlVlJPlZUaUMEAPb/74kWurVrmiAQaXxhgqmPQ6Hnae6OA2H5rPCpacHupSC3En2r01MI875/vCZhXKCyXX570Z1iqqbH+M+vmN2uenFL0eZqe/iXuF1Kl7SKS88cngIqnOIPFMz26boRqcP+NOjisTXb4+qnofBc= paramah@rork"
s.inline = <<-SHELL
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
sudo apt-get -y install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get -y update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
SHELL
end
end
end
end