Add support for a nat-less libvirt deployment and multiple workers
This commit is contained in:
parent
dbf51c823e
commit
21bc78b77d
94
deploy/vagrant/Vagrantfile
vendored
94
deploy/vagrant/Vagrantfile
vendored
@ -1,5 +1,7 @@
|
|||||||
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
|
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
|
||||||
|
|
||||||
|
num_workers = ENV['TINKERBELL_NUM_WORKERS'] || '1'
|
||||||
|
|
||||||
# Returns true if `GUI` environment variable exists, value does not matter.
|
# Returns true if `GUI` environment variable exists, value does not matter.
|
||||||
# Defaults to false
|
# Defaults to false
|
||||||
def worker_gui_enabled?
|
def worker_gui_enabled?
|
||||||
@ -12,6 +14,14 @@ def worker_display_scale_enabled?
|
|||||||
ENV.include?('VAGRANT_WORKER_SCALE')
|
ENV.include?('VAGRANT_WORKER_SCALE')
|
||||||
end
|
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|
|
Vagrant.configure('2') do |config|
|
||||||
|
|
||||||
config.vm.define :provisioner do |provisioner|
|
config.vm.define :provisioner do |provisioner|
|
||||||
@ -19,7 +29,11 @@ Vagrant.configure('2') do |config|
|
|||||||
provisioner.vm.box_version = "0.1.0"
|
provisioner.vm.box_version = "0.1.0"
|
||||||
provisioner.vm.hostname = 'provisioner'
|
provisioner.vm.hostname = 'provisioner'
|
||||||
provisioner.vm.synced_folder './../../', '/vagrant'
|
provisioner.vm.synced_folder './../../', '/vagrant'
|
||||||
provisioner.vm.provision :shell, path: './scripts/tinkerbell.sh'
|
provisioner.vm.provision :shell,
|
||||||
|
path: './scripts/tinkerbell.sh',
|
||||||
|
env: {
|
||||||
|
'TINKERBELL_CONFIGURE_NAT': configure_nat,
|
||||||
|
}
|
||||||
|
|
||||||
provisioner.vm.network :private_network,
|
provisioner.vm.network :private_network,
|
||||||
virtualbox__intnet: "tink_network",
|
virtualbox__intnet: "tink_network",
|
||||||
@ -27,7 +41,7 @@ Vagrant.configure('2') do |config|
|
|||||||
libvirt__host_ip: "192.168.1.6",
|
libvirt__host_ip: "192.168.1.6",
|
||||||
libvirt__netmask: "255.255.255.248",
|
libvirt__netmask: "255.255.255.248",
|
||||||
libvirt__dhcp_enabled: false,
|
libvirt__dhcp_enabled: false,
|
||||||
libvirt__forward_mode: 'none',
|
libvirt__forward_mode: libvirt_forward_mode,
|
||||||
libvirt__adapter: 1,
|
libvirt__adapter: 1,
|
||||||
auto_config: false
|
auto_config: false
|
||||||
|
|
||||||
@ -47,43 +61,49 @@ Vagrant.configure('2') do |config|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.define "worker" do |worker|
|
|
||||||
worker.vm.box = nil
|
|
||||||
worker.vm.network :private_network,
|
|
||||||
mac: "080027000001",
|
|
||||||
virtualbox__intnet: "tink_network",
|
|
||||||
libvirt__network_name: "tink_network",
|
|
||||||
libvirt__dhcp_enabled: false,
|
|
||||||
libvirt__forward_mode: 'none',
|
|
||||||
auto_config: false
|
|
||||||
|
|
||||||
worker.vm.provider :libvirt do |lv|
|
(1..num_workers.to_i).each do |i|
|
||||||
lv.memory = 4*1024
|
mac_suffix = "%02x" % i
|
||||||
lv.cpus = 1
|
worker_suffix = i==1 ? "" : "i"
|
||||||
lv.boot 'network'
|
config.vm.define "worker#{worker_suffix}" do |worker|
|
||||||
lv.mgmt_attach = false
|
|
||||||
lv.storage :file, :size => '40G'
|
worker.vm.box = nil
|
||||||
lv.random :model => 'random'
|
worker.vm.network :private_network,
|
||||||
end
|
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 :virtualbox do |vb, worker|
|
worker.vm.provider :libvirt do |lv|
|
||||||
worker.vm.box = 'generic/alpine38'
|
lv.memory = 4*1024
|
||||||
vb.memory = 4*1024
|
lv.cpus = 1
|
||||||
vb.cpus = 1
|
lv.boot 'network'
|
||||||
vb.gui = worker_gui_enabled?
|
lv.mgmt_attach = false
|
||||||
vb.customize [
|
lv.storage :file, :size => '40G'
|
||||||
'setextradata', :id,
|
lv.random :model => 'random'
|
||||||
'GUI/ScaleFactor', '3.0'
|
end
|
||||||
] if worker_display_scale_enabled?
|
|
||||||
vb.customize [
|
worker.vm.provider :virtualbox do |vb, worker|
|
||||||
'modifyvm', :id,
|
worker.vm.box = 'generic/alpine38'
|
||||||
'--nic1', 'none',
|
vb.memory = 4*1024
|
||||||
'--boot1', 'net',
|
vb.cpus = 1
|
||||||
'--boot2', 'none',
|
vb.gui = worker_gui_enabled?
|
||||||
'--boot3', 'none',
|
vb.customize [
|
||||||
'--boot4', 'none',
|
'setextradata', :id,
|
||||||
'--macaddress1', '080027000001'
|
'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
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,10 +45,12 @@ main() (
|
|||||||
|
|
||||||
./setup.sh
|
./setup.sh
|
||||||
|
|
||||||
setup_nat
|
if [[ ${TINKERBELL_CONFIGURE_NAT:=true} != "false" ]]; then
|
||||||
|
setup_nat
|
||||||
|
fi
|
||||||
|
|
||||||
secure_certs
|
secure_certs
|
||||||
configure_vagrant_user
|
configure_vagrant_user
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
main
|
main
|
||||||
|
Loading…
Reference in New Issue
Block a user