Skip to content

Commit 8c67d0b

Browse files
committed
tf: Put all setup logic in setup.sh
No sense in splitting up the setup logic into 2 different files. Signed-off-by: Manuel Mendez <[email protected]>
1 parent 14ffb7c commit 8c67d0b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

deploy/terraform/main.tf

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,7 @@ resource "null_resource" "setup" {
105105

106106
provisioner "remote-exec" {
107107
inline = [
108-
"echo '===== running setup.sh ====='",
109-
"chmod +x /tmp/setup.sh && /tmp/setup.sh",
110-
"echo '===== extracting compose tarball ====='",
111-
"tar -vxz -f /root/compose.tar.gz -C /root/sandbox",
112-
"echo '===== setting up docker-compose .env overrides ====='",
113-
"echo TINKERBELL_CLIENT_MAC=${local.worker_macs[0]} >>/root/sandbox/compose/.env",
114-
"echo TINKERBELL_TEMPLATE_MANIFEST=/manifests/template/ubuntu-equinix-metal.yaml >>/root/sandbox/compose/.env",
115-
"echo TINKERBELL_HARDWARE_MANIFEST=/manifests/hardware/hardware-equinix-metal.json >>/root/sandbox/compose/.env",
116-
"echo '===== bringing up docker-compose stack ====='",
117-
"docker-compose -f /root/sandbox/compose/docker-compose.yml up -d"
108+
"chmod +x /tmp/setup.sh && /tmp/setup.sh ${local.worker_macs[0]}",
118109
]
119110
}
120111
}

deploy/terraform/setup.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,41 @@ make_host_gw_server() {
108108
systemctl start docker
109109
}
110110

111+
extract_compose_files() {
112+
mkdir -p /root/sandbox
113+
tar -zxvf /root/compose.tar.gz -C /root/sandbox
114+
}
115+
116+
setup_compose_env_overrides() {
117+
local worker_mac=$1
118+
readarray lines <<-EOF
119+
TINKERBELL_CLIENT_MAC=$worker_mac
120+
TINKERBELL_TEMPLATE_MANIFEST=/manifests/template/ubuntu-equinix-metal.yaml
121+
TINKERBELL_HARDWARE_MANIFEST=/manifests/hardware/hardware-equinix-metal.json
122+
EOF
123+
for line in "${lines[@]}"; do
124+
grep -q "$line" /root/sandbox/compose/.env && continue
125+
echo "$line" >>/root/sandbox/compose/.env
126+
done
127+
}
128+
111129
main() {
130+
worker_mac=$1
131+
layer2_ip=192.168.56.4
132+
112133
update_apt
113134
install_docker
114135
install_docker_compose
115136
install_iptables_persistent
116137

117-
local layer2_ip=192.168.56.4
118138
local layer2_interface
119139
layer2_interface=$(get_second_interface_from_bond0 ${layer2_ip})
120140
setup_layer2_network "${layer2_interface}" ${layer2_ip}
121141
make_host_gw_server "${layer2_interface}" bond0
122142

123-
mkdir -p /root/sandbox/compose
143+
extract_compose_files
144+
setup_compose_env_overrides "$worker_mac"
145+
docker-compose -f /root/sandbox/compose/docker-compose.yml up -d
124146
}
125147

126148
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then

0 commit comments

Comments
 (0)