Reduce reboot time

This commit is contained in:
Marco Nenciarini 2022-02-07 09:11:07 +01:00
parent 919e1087f8
commit cf68368eea
No known key found for this signature in database
GPG Key ID: 589F03F01BA55038
4 changed files with 20 additions and 9 deletions

View File

@ -43,9 +43,14 @@ resource "hcloud_server" "agents" {
} }
} }
# Issue a reboot command
provisioner "local-exec" {
command = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
}
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "sleep 60 && ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 60" command = "until ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done"
} }
# Generating and uploading the angent.conf file # Generating and uploading the angent.conf file

View File

@ -17,18 +17,14 @@ locals {
"aria2c --follow-metalink=mem https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-k3s-kvm-and-xen.qcow2.meta4", "aria2c --follow-metalink=mem https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-k3s-kvm-and-xen.qcow2.meta4",
"qemu-img convert -p -f qcow2 -O host_device $(ls -a | grep -ie '^opensuse.*microos.*k3s.*qcow2$') /dev/sda", "qemu-img convert -p -f qcow2 -O host_device $(ls -a | grep -ie '^opensuse.*microos.*k3s.*qcow2$') /dev/sda",
"sgdisk -e /dev/sda", "sgdisk -e /dev/sda",
"partprobe /dev/sda",
"parted -s /dev/sda resizepart 4 99%", "parted -s /dev/sda resizepart 4 99%",
"parted -s /dev/sda mkpart primary ext2 99% 100%", "parted -s /dev/sda mkpart primary ext2 99% 100%",
"udevadm settle", "partprobe /dev/sda",
"mount /dev/sda4 /mnt/ && btrfs filesystem resize max /mnt && umount /mnt", "mount /dev/sda4 /mnt/ && btrfs filesystem resize max /mnt && umount /mnt",
"mke2fs -L ignition /dev/sda5", "mke2fs -L ignition /dev/sda5",
"mount /dev/sda5 /mnt", "mount /dev/sda5 /mnt",
"mkdir /mnt/ignition", "mkdir /mnt/ignition",
"cp /root/config.ign /mnt/ignition/config.ign", "cp /root/config.ign /mnt/ignition/config.ign",
"umount /mnt", "umount /mnt"
"shutdown -r +1",
"sleep 1",
"exit 0"
] ]
} }

View File

@ -41,9 +41,14 @@ resource "hcloud_server" "first_control_plane" {
} }
} }
# Issue a reboot command
provisioner "local-exec" {
command = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
}
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "sleep 60 && ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 60" command = "until ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done"
} }
# Generating k3s master config file # Generating k3s master config file

View File

@ -42,9 +42,14 @@ resource "hcloud_server" "control_planes" {
} }
} }
# Issue a reboot command
provisioner "local-exec" {
command = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
}
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "sleep 60 && ping ${self.ipv4_address} | grep --line-buffered 'bytes from' | head -1 && sleep 60" command = "until ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done"
} }
# Generating k3s server config file # Generating k3s server config file