This commit is contained in:
Karim Naufal
2021-12-03 02:11:52 +01:00
parent 61f8093951
commit 8113016f86
8 changed files with 217 additions and 43 deletions

27
main.tf
View File

@@ -88,23 +88,24 @@ resource "hcloud_firewall" "k3s" {
}
}
data "hcloud_image" "linux" {
name = "ubuntu-20.04"
}
locals {
first_control_plane_network_ip = cidrhost(hcloud_network.k3s.ip_range, 2)
name_master = "k3s-control-plane-0"
ssh_public_key = trimspace(file(var.public_key))
hcloud_image_name = "ubuntu-20.04"
k3os_install_commands = [
"apt install -y grub-efi grub-pc-bin mtools xorriso",
"latest=$(curl -s https://api.github.com/repos/rancher/k3os/releases | jq '.[0].tag_name')",
"curl -Lo ./install.sh https://raw.githubusercontent.com/rancher/k3os/$(echo $latest | xargs)/install.sh",
"chmod +x ./install.sh",
"./install.sh --config /tmp/config.yaml /dev/sda https://github.com/rancher/k3os/releases/download/$(echo $latest | xargs)/k3os-amd64.iso",
"shutdown -r +1",
"sleep 3",
"exit 0"
]
}
data "template_file" "master" {
template = file("${path.module}/templates/master.tpl")
vars = {
name = local.name_master
ssh_public_key = local.ssh_public_key
k3s_token = random_password.k3s_token.result
ip = local.first_control_plane_network_ip
}
data "hcloud_image" "linux" {
name = local.hcloud_image_name
}