Skip to content

Commit

Permalink
Use the same folder path on both terraform and vagrant
Browse files Browse the repository at this point in the history
Better to have everything look the same for easier diffing/comparing
vs having the tool name in the path.
  • Loading branch information
mmlb committed Mar 18, 2022
1 parent 2e78fc3 commit 98ce1be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions deploy/terraform/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ make_host_gw_server() {
}

extract_compose_files() {
mkdir -p /root/sandbox
tar -zxvf /root/compose.tar.gz -C /root/sandbox
mkdir -p /sandbox
tar -zxvf /root/compose.tar.gz -C /sandbox
}

setup_compose_env_overrides() {
Expand All @@ -121,22 +121,22 @@ setup_compose_env_overrides() {
TINKERBELL_HARDWARE_MANIFEST=/manifests/hardware/hardware-equinix-metal.json
EOF
for line in "${lines[@]}"; do
grep -q "$line" /root/sandbox/compose/.env && continue
echo "$line" >>/root/sandbox/compose/.env
grep -q "$line" /sandbox/compose/.env && continue
echo "$line" >>/sandbox/compose/.env
done
}

create_tink_helper_script() {
cat >/usr/local/bin/tink <<-'EOF'
#!/usr/bin/env bash
exec docker-compose -f /root/sandbox/compose/docker-compose.yml exec tink-cli tink "$@"
exec docker-compose -f /sandbox/compose/docker-compose.yml exec tink-cli tink "$@"
EOF
chmod +x /usr/local/bin/tink
}

tweak_bash_interactive_settings() {
grep -q 'cd /root/sandbox/compose' ~root/.bashrc || echo 'cd /root/sandbox/compose' >>~root/.bashrc
grep -q 'cd /sandbox/compose' ~root/.bashrc || echo 'cd /sandbox/compose' >>~root/.bashrc
readarray aliases <<-EOF
dc=docker-compose
EOF
Expand All @@ -161,7 +161,7 @@ main() {

extract_compose_files
setup_compose_env_overrides "$worker_mac"
docker-compose -f /root/sandbox/compose/docker-compose.yml up -d
docker-compose -f /sandbox/compose/docker-compose.yml up -d

create_tink_helper_script
tweak_bash_interactive_settings
Expand Down
6 changes: 3 additions & 3 deletions deploy/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Vagrant.configure("2") do |config|

config.vm.define "provisioner" do |provisioner|
provisioner.vm.box = "generic/ubuntu2004"
provisioner.vm.synced_folder "../compose/", "/vagrant/compose/"
provisioner.vm.synced_folder "../compose/", "/sandbox/compose/"
provisioner.vm.network "private_network", ip: PROVISIONER_IP,
libvirt__network_name: "tink_network",
libvirt__host_ip: "192.168.56.1",
Expand All @@ -28,13 +28,13 @@ Vagrant.configure("2") do |config|
provisioner.vm.provider "virtualbox" do |v, override|
v.memory = 2048
v.cpus = 2
override.vm.synced_folder "../compose/", "/vagrant/compose/"
override.vm.synced_folder "../compose/", "/sandbox/compose/"
end

provisioner.vm.provider "libvirt" do |l, override|
l.memory = 2048
l.cpus = 2
override.vm.synced_folder "../compose/", "/vagrant/compose/", type: "rsync"
override.vm.synced_folder "../compose/", "/sandbox/compose/", type: "rsync"
end

provisioner.vm.provision :docker
Expand Down
12 changes: 6 additions & 6 deletions deploy/vagrant/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ setup_compose_env_overrides() {
local host_addr=$1
local worker_addr=$2
if lsblk | grep -q vda; then
sed -i 's|sda|vda|g' /vagrant/compose/create-tink-records/manifests/template/ubuntu.yaml
sed -i 's|sda|vda|g' /sandbox/compose/create-tink-records/manifests/template/ubuntu.yaml
fi
readarray lines <<-EOF
TINKERBELL_HOST_IP="$host_addr"
TINKERBELL_CLIENT_IP="$worker_addr"
EOF
for line in "${lines[@]}"; do
grep -q "$line" /vagrant/compose/.env && continue
echo "$line" >>/vagrant/compose/.env
grep -q "$line" /sandbox/compose/.env && continue
echo "$line" >>/sandbox/compose/.env
done
}

Expand All @@ -28,13 +28,13 @@ create_tink_helper_script() {
cat >~vagrant/.local/bin/tink <<-'EOF'
#!/usr/bin/env bash
exec docker-compose -f /vagrant/compose/docker-compose.yml exec tink-cli tink "$@"
exec docker-compose -f /sandbox/compose/docker-compose.yml exec tink-cli tink "$@"
EOF
chmod +x ~vagrant/.local/bin/tink
}

tweak_bash_interactive_settings() {
grep -q 'cd /vagrant/compose' ~vagrant/.bashrc || echo 'cd /vagrant/compose' >>~vagrant/.bashrc
grep -q 'cd /sandbox/compose' ~vagrant/.bashrc || echo 'cd /sandbox/compose' >>~vagrant/.bashrc
readarray aliases <<-EOF
dc=docker-compose
EOF
Expand All @@ -50,7 +50,7 @@ main() {
setup_layer2_network "$host_addr"

setup_compose_env_overrides "$host_addr" "$worker_addr"
docker-compose -f /vagrant/compose/docker-compose.yml up -d
docker-compose -f /sandbox/compose/docker-compose.yml up -d

create_tink_helper_script
tweak_bash_interactive_settings
Expand Down

0 comments on commit 98ce1be

Please sign in to comment.