-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from gauravgahlot/vagrant
Setup tinkerbell stack locally using Vagrant
- Loading branch information
Showing
4 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ cmd/tink-worker/tink-worker | |
.terraform | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
|
||
# Vagrant | ||
**/.vagrant |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
ENV['VAGRANT_NO_PARALLEL'] = 'yes' | ||
|
||
Vagrant.configure('2') do |config| | ||
|
||
config.vm.define :provisioner do |provisioner| | ||
provisioner.vm.box = 'generic/ubuntu1804' | ||
provisioner.vm.hostname = 'provisioner' | ||
provisioner.vm.synced_folder './../../', '/vagrant' | ||
provisioner.vm.provision :shell, path: './scripts/tinkerbell.sh' | ||
|
||
provisioner.vm.network :private_network, | ||
virtualbox__intnet: "tink_network", | ||
libvirt__dhcp_enabled: false, | ||
libvirt__forward_mode: 'none', | ||
auto_config: false | ||
|
||
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 | ||
|
||
config.vm.define "worker" do |worker| | ||
worker.vm.box = nil | ||
worker.vm.network :private_network, | ||
mac: "080027000001", | ||
virtualbox__intnet: "tink_network", | ||
libvirt__dhcp_enabled: false, | ||
libvirt__forward_mode: 'none', | ||
auto_config: false | ||
|
||
worker.vm.provider :libvirt do |lv| | ||
lv.memory = 1*1024 | ||
lv.cpus = 1 | ||
lv.boot 'network' | ||
lv.mgmt_attach = false | ||
end | ||
|
||
worker.vm.provider :virtualbox do |vb, worker| | ||
worker.vm.box = 'generic/alpine38' | ||
vb.memory = 1*1024 | ||
vb.cpus = 1 | ||
vb.gui = true | ||
vb.customize [ | ||
'modifyvm', :id, | ||
'--nic1', 'none', | ||
'--boot1', 'net', | ||
'--boot2', 'none', | ||
'--boot3', 'none', | ||
'--boot4', 'none', | ||
'--macaddress1', '080027000001' | ||
] | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
# abort this script on errors | ||
set -euxo pipefail | ||
|
||
whoami | ||
|
||
cd /vagrant | ||
|
||
setup_docker() ( | ||
# steps from https://docs.docker.com/engine/install/ubuntu/ | ||
sudo apt-get install -y \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg-agent \ | ||
software-properties-common | ||
|
||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | | ||
sudo apt-key add - | ||
|
||
local repo | ||
repo=$( | ||
printf "deb [arch=amd64] https://download.docker.com/linux/ubuntu %s stable" \ | ||
"$(lsb_release -cs)" | ||
) | ||
sudo add-apt-repository "$repo" | ||
|
||
sudo apt-get update | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | ||
) | ||
|
||
setup_docker_compose() ( | ||
# from https://docs.docker.com/compose/install/ | ||
sudo curl -L \ | ||
"https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" \ | ||
-o /usr/local/bin/docker-compose | ||
|
||
sudo chmod +x /usr/local/bin/docker-compose | ||
) | ||
|
||
make_certs_writable() ( | ||
local certdir="/etc/docker/certs.d/$TINKERBELL_HOST_IP" | ||
sudo mkdir -p "$certdir" | ||
sudo chown -R "$USER" "$certdir" | ||
) | ||
|
||
secure_certs() ( | ||
local certdir="/etc/docker/certs.d/$TINKERBELL_HOST_IP" | ||
sudo chown "root" "$certdir" | ||
) | ||
|
||
command_exists() ( | ||
command -v "$@" >/dev/null 2>&1 | ||
) | ||
|
||
configure_vagrant_user() ( | ||
sudo usermod -aG docker vagrant | ||
|
||
echo -n "$TINKERBELL_REGISTRY_PASSWORD" | | ||
sudo -iu vagrant docker login \ | ||
--username="$TINKERBELL_REGISTRY_USERNAME" \ | ||
--password-stdin "$TINKERBELL_HOST_IP" | ||
) | ||
|
||
main() ( | ||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt-get update | ||
|
||
if ! command_exists docker; then | ||
setup_docker | ||
fi | ||
|
||
if ! command_exists docker-compose; then | ||
setup_docker_compose | ||
fi | ||
|
||
if ! command_exists jq; then | ||
sudo apt-get install -y jq | ||
fi | ||
|
||
if [ ! -f ./envrc ]; then | ||
./generate-envrc.sh eth1 >envrc | ||
fi | ||
|
||
# shellcheck disable=SC1091 | ||
. ./envrc | ||
|
||
make_certs_writable | ||
|
||
./setup.sh | ||
|
||
secure_certs | ||
|
||
configure_vagrant_user | ||
|
||
) | ||
|
||
main |
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