Created
October 11, 2021 10:55
-
-
Save bartosz-gorny/5b2da5aa5b323575b4435a0ea2d5fc53 to your computer and use it in GitHub Desktop.
Vagrant template for multi node setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domain = 'example.com' | |
nodes = [ | |
{ hostname: 'lb01', ip: '192.168.250.10', box: 'ubuntu/bionic64', cpus: '1', ram: '256' }, | |
{ hostname: 'node01', ip: '192.168.250.21', box: 'ubuntu/bionic64', cpus: '1', ram: '256' }, | |
{ hostname: 'node02', ip: '192.168.250.22', box: 'ubuntu/bionic64', cpus: '1', ram: '256' }, | |
{ hostname: 'node03', ip: '192.168.250.23', box: 'ubuntu/bionic64', cpus: '1', ram: '256' }, | |
] | |
Vagrant.configure('2') do |config| | |
nodes.each do |node| | |
config.vm.define node[:hostname] do |nodeconfig| | |
nodeconfig.vm.box = node[:box] ? node[:box] : 'ubuntu/trusty64' | |
nodeconfig.ssh.insert_key = false | |
nodeconfig.vm.hostname = node[:hostname] + '.' + domain | |
nodeconfig.vm.network :private_network, ip: node[:ip] | |
cpus = node[:cpus] ? node[:cpus] : 1 | |
memory = node[:ram] ? node[:ram] : 256 | |
nodeconfig.vm.provider :virtualbox do |vb| | |
vb.customize [ | |
'modifyvm', :id, | |
'--cpuexecutioncap', '100', | |
'--cpus', cpus.to_s, | |
'--memory', memory.to_s | |
] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment