Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit ac9c2b3

Browse files
pothosImran Pochi
authored andcommitted
baremetal: run copy-controller-secrets step after recreating the node
1 parent 430e46d commit ac9c2b3

File tree

3 files changed

+106
-23
lines changed

3 files changed

+106
-23
lines changed

assets/terraform-modules/matchbox-flatcar/pxe-helper.sh.tmpl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
name=${name}
44
domain=${domain}
55
mac=${mac}
6-
asset_dir=${asset_dir}
6+
asset_dir="${asset_dir}"
7+
kernel_args="${kernel_args}"
8+
kernel_console="${kernel_console}"
9+
ignition_endpoint="${ignition_endpoint}"
710
type=${type}
811
# From now on use $var for dynamic shell substitution
912

@@ -20,6 +23,7 @@ if [ $node_exists = yes ]; then
2023
echo "Keeping old config because replacing a controller node is not safe"
2124
exit 0
2225
else
26+
# run single commands that can be retried without a side effect in case the connection got disrupted
2327
count=30
2428
while [ $count -gt 0 ] && ! ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NumberOfPasswordPrompts=0 core@$domain sudo touch /boot/flatcar/first_boot; do
2529
sleep 1
@@ -31,6 +35,15 @@ if [ $node_exists = yes ]; then
3135
fi
3236
echo "created the first_boot flag file to reprovision $domain"
3337
count=5
38+
while [ $count -gt 0 ] && ! ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NumberOfPasswordPrompts=0 core@$domain "printf 'set linux_append=\"$kernel_args ignition.config.url=$ignition_endpoint?mac=$mac&os=installed\"\\nset linux_console=\"$kernel_console\"\\n' | sudo tee /usr/share/oem/grub.cfg"; do
39+
sleep 1
40+
count=$((count - 1))
41+
done
42+
if [ $count -eq 0 ]; then
43+
echo "error reaching $domain via SSH, please retry"
44+
exit 1
45+
fi
46+
count=5
3447
while [ $count -gt 0 ] && ! ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NumberOfPasswordPrompts=0 core@$domain sudo systemctl reboot; do
3548
sleep 1
3649
count=$((count - 1))

assets/terraform-modules/matchbox-flatcar/ssh.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ resource "null_resource" "reprovision-node-when-ignition-changes" {
77
depends_on = [matchbox_group.node]
88
# Trigger running Ignition on the next reboot (first_boot flag file) and reboot the instance, or, if the instance needs to be (re)provisioned, run external commands for PXE booting (also runs on the first provisioning)
99
provisioner "local-exec" {
10-
command = templatefile("${path.module}/pxe-helper.sh.tmpl", { domain = var.node_domain, name = var.node_name, mac = var.node_mac, pxe_commands = var.pxe_commands, asset_dir = var.asset_dir, type = "node" })
10+
command = templatefile("${path.module}/pxe-helper.sh.tmpl", { domain = var.node_domain, name = var.node_name, mac = var.node_mac, pxe_commands = var.pxe_commands, asset_dir = var.asset_dir, kernel_args = join(" ", var.kernel_args), kernel_console = join(" ", var.kernel_console), ignition_endpoint = format("%s/ignition", var.http_endpoint), type = "node" })
1111
}
1212
}

0 commit comments

Comments
 (0)