diff --git a/locals.tf b/locals.tf index 51687b1..983461c 100644 --- a/locals.tf +++ b/locals.tf @@ -13,8 +13,9 @@ locals { microOS_install_commands = [ "set -ex", - "aria2c https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2.meta4", - "qemu-img convert -p -f qcow2 -O host_device $(ls -a | grep MicroOS | grep -v meta4) /dev/sda", + "apt install -y aria2", + "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", "sgdisk -e /dev/sda", "partprobe /dev/sda", "parted -s /dev/sda resizepart 4 99%", diff --git a/master.tf b/master.tf index 01bbecd..8fa2da1 100644 --- a/master.tf +++ b/master.tf @@ -31,6 +31,20 @@ resource "hcloud_server" "first_control_plane" { } } + provisioner "file" { + content = templatefile("${path.module}/templates/config.ign.tpl", { + ssh_public_key = local.ssh_public_key + }) + destination = "/root/config.ign" + + connection { + user = "root" + private_key = local.ssh_private_key + agent_identity = local.ssh_identity + host = self.ipv4_address + } + } + # Install k3os provisioner "remote-exec" { inline = local.microOS_install_commands @@ -42,7 +56,7 @@ resource "hcloud_server" "first_control_plane" { host = self.ipv4_address } } - + /* # Wait for MicroOS to be ready and fetch kubeconfig.yaml provisioner "local-exec" { command = <<-EOT @@ -65,7 +79,7 @@ resource "hcloud_server" "first_control_plane" { provisioner "local-exec" { command = "kubectl apply -f ${local_file.traefik_config.filename} --kubeconfig ${path.module}/kubeconfig.yaml" } - +*/ network { network_id = hcloud_network.k3s.id ip = local.first_control_plane_network_ip diff --git a/agents.tf b/temp/agents.tf similarity index 100% rename from agents.tf rename to temp/agents.tf diff --git a/output.tf b/temp/output.tf similarity index 100% rename from output.tf rename to temp/output.tf diff --git a/servers.tf b/temp/servers.tf similarity index 100% rename from servers.tf rename to temp/servers.tf diff --git a/templates/config.ign.tpl b/templates/config.ign.tpl new file mode 100644 index 0000000..3be1a77 --- /dev/null +++ b/templates/config.ign.tpl @@ -0,0 +1,15 @@ +{ + "ignition": { + "version": "3.0.0" + }, + "passwd": { + "users": [ + { + "name": "root", + "sshAuthorizedKeys": [ + "${ssh_public_key}" + ] + } + ] + } +}