9bea6a01df
https://app.vagrantup.com/tinkerbelloss/boxes/sandbox-ubuntu1804/versions/0.2.0 exist now as a fix for #59 and #62. Signed-off-by: Manuel Mendez <mmendez@equinix.com>
110 lines
3.4 KiB
Ruby
110 lines
3.4 KiB
Ruby
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
|
|
|
|
num_workers = ENV['TINKERBELL_NUM_WORKERS'] || '1'
|
|
|
|
# Returns true if `GUI` environment variable exists, value does not matter.
|
|
# Defaults to false
|
|
def worker_gui_enabled?
|
|
ENV.include?('VAGRANT_WORKER_GUI')
|
|
end
|
|
|
|
# Returns true if `SCALE` environment variable exists, value does not matter.
|
|
# Defaults to false
|
|
def worker_display_scale_enabled?
|
|
ENV.include?('VAGRANT_WORKER_SCALE')
|
|
end
|
|
|
|
def configure_nat
|
|
return ENV.has_key?('TINKERBELL_CONFIGURE_NAT') ? ENV['TINKERBELL_CONFIGURE_NAT'] : 'true'
|
|
end
|
|
|
|
def libvirt_forward_mode
|
|
return configure_nat == 'false' ? 'nat' : 'none'
|
|
end
|
|
|
|
Vagrant.configure('2') do |config|
|
|
|
|
config.vm.define :provisioner do |provisioner|
|
|
provisioner.vm.box = "tinkerbelloss/sandbox-ubuntu1804"
|
|
provisioner.vm.box_version = "0.2.0"
|
|
provisioner.vm.hostname = 'provisioner'
|
|
provisioner.vm.synced_folder './../../', '/vagrant'
|
|
provisioner.vm.provision :shell,
|
|
path: './scripts/tinkerbell.sh',
|
|
env: {
|
|
'TINKERBELL_CONFIGURE_NAT': configure_nat,
|
|
}
|
|
|
|
provisioner.vm.network :private_network,
|
|
virtualbox__intnet: "tink_network",
|
|
libvirt__network_name: "tink_network",
|
|
libvirt__host_ip: "192.168.1.6",
|
|
libvirt__netmask: "255.255.255.248",
|
|
libvirt__dhcp_enabled: false,
|
|
libvirt__forward_mode: libvirt_forward_mode,
|
|
libvirt__adapter: 1,
|
|
auto_config: false
|
|
|
|
provisioner.vm.network "forwarded_port", guest: 42113, host: 42113
|
|
provisioner.vm.network "forwarded_port", guest: 42114, host: 42114
|
|
|
|
|
|
provisioner.vm.provider :libvirt do |lv, override|
|
|
lv.memory = 2*1024
|
|
lv.cpus = 2
|
|
lv.cpu_mode = 'host-passthrough'
|
|
end
|
|
|
|
provisioner.vm.provider :virtualbox do |vb, override|
|
|
vb.memory = 2*1024
|
|
vb.cpus = 2
|
|
end
|
|
end
|
|
|
|
|
|
(1..num_workers.to_i).each do |i|
|
|
mac_suffix = "%02x" % i
|
|
worker_suffix = i==1 ? "" : "i"
|
|
config.vm.define "worker#{worker_suffix}" do |worker|
|
|
|
|
worker.vm.box = nil
|
|
worker.vm.network :private_network,
|
|
mac: "0800270000#{mac_suffix}",
|
|
virtualbox__intnet: "tink_network",
|
|
libvirt__network_name: "tink_network",
|
|
libvirt__dhcp_enabled: false,
|
|
libvirt__forward_mode: libvirt_forward_mode,
|
|
auto_config: false
|
|
|
|
worker.vm.provider :libvirt do |lv|
|
|
lv.memory = 4*1024
|
|
lv.cpus = 1
|
|
lv.boot 'network'
|
|
lv.mgmt_attach = false
|
|
lv.storage :file, :size => '40G'
|
|
lv.random :model => 'random'
|
|
end
|
|
|
|
worker.vm.provider :virtualbox do |vb, worker|
|
|
worker.vm.box = 'generic/alpine38'
|
|
vb.memory = 4*1024
|
|
vb.cpus = 1
|
|
vb.gui = worker_gui_enabled?
|
|
vb.customize [
|
|
'setextradata', :id,
|
|
'GUI/ScaleFactor', '3.0'
|
|
] if worker_display_scale_enabled?
|
|
vb.customize [
|
|
'modifyvm', :id,
|
|
'--nic1', 'none',
|
|
'--boot1', 'net',
|
|
'--boot2', 'none',
|
|
'--boot3', 'none',
|
|
'--boot4', 'none',
|
|
'--macaddress1', "0800270000#{mac_suffix}"
|
|
]
|
|
end
|
|
end
|
|
end
|
|
end
|