vagrant-lab-swarm/Vagrantfile

53 lines
2.3 KiB
Ruby
Raw Normal View History

2022-11-11 13:07:35 +00:00
# to make sure the nodes are created in order, we
# have to force a --no-parallel execution.
2022-11-11 13:12:49 +00:00
# ENV['VAGRANT_NO_PARALLEL'] = 'yes'
2022-11-11 13:07:35 +00:00
require 'ipaddr'
2023-12-10 10:46:51 +00:00
number_of_server_nodes = 1
2022-11-11 13:07:35 +00:00
domain = "dexter.lab"
Vagrant.configure(2) do |config|
2023-12-10 10:46:51 +00:00
config.vm.box = 'bento/amazonlinux-2'
2022-11-11 13:07:35 +00:00
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
2022-11-11 13:10:54 +00:00
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
2022-11-20 13:05:28 +00:00
if [ -f /vagrant/join.sh ]; then /vagrant/join.sh; else echo "/vagrant/join.sh not found!"; fi
2022-11-11 13:07:35 +00:00
SHELL
end
end
end
end