Add support for a nat-less libvirt deployment and multiple workers (#65)

## Description

Allows for deploying the vagrant/libvirt setup without NAT and with multiple workers, which enables testing with cluster-api-provider-tink

## Why is this needed

Helps with testing CAPT

## How Has This Been Tested?

Currently testing at the moment, but all testing will consist of manual testing with vagrant/libvirt

## How are existing users impacted? What migration steps/scripts do we need?

This could affect existing vagrant/libvirt users if they have an existing worker running when they update, not sure if there is a good way to avoid that, though.


## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
This commit is contained in:
mergify[bot] 2021-03-19 07:54:59 +00:00 committed by GitHub
commit 193a2fa83c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 39 deletions

View File

@ -1,5 +1,7 @@
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?
@ -12,6 +14,14 @@ 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|
@ -19,7 +29,11 @@ Vagrant.configure('2') do |config|
provisioner.vm.box_version = "0.1.0"
provisioner.vm.hostname = 'provisioner'
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,
virtualbox__intnet: "tink_network",
@ -27,7 +41,7 @@ Vagrant.configure('2') do |config|
libvirt__host_ip: "192.168.1.6",
libvirt__netmask: "255.255.255.248",
libvirt__dhcp_enabled: false,
libvirt__forward_mode: 'none',
libvirt__forward_mode: libvirt_forward_mode,
libvirt__adapter: 1,
auto_config: false
@ -47,14 +61,19 @@ Vagrant.configure('2') do |config|
end
end
config.vm.define "worker" do |worker|
(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: "080027000001",
mac: "0800270000#{mac_suffix}",
virtualbox__intnet: "tink_network",
libvirt__network_name: "tink_network",
libvirt__dhcp_enabled: false,
libvirt__forward_mode: 'none',
libvirt__forward_mode: libvirt_forward_mode,
auto_config: false
worker.vm.provider :libvirt do |lv|
@ -82,8 +101,9 @@ Vagrant.configure('2') do |config|
'--boot2', 'none',
'--boot3', 'none',
'--boot4', 'none',
'--macaddress1', '080027000001'
'--macaddress1', "0800270000#{mac_suffix}"
]
end
end
end
end

View File

@ -45,10 +45,12 @@ main() (
./setup.sh
if [[ ${TINKERBELL_CONFIGURE_NAT:=true} != "false" ]]; then
setup_nat
fi
secure_certs
configure_vagrant_user
)
main