diff --git a/agents.tf b/agents.tf index 39562e6..7e9724e 100644 --- a/agents.tf +++ b/agents.tf @@ -24,10 +24,7 @@ resource "hcloud_server" "agents" { } provisioner "file" { - content = templatefile("${path.module}/templates/config.ign.tpl", { - name = self.name - ssh_public_key = local.ssh_public_key - }) + content = local.ignition_config destination = "/root/config.ign" } diff --git a/locals.tf b/locals.tf index 6c5a399..ce74971 100644 --- a/locals.tf +++ b/locals.tf @@ -38,6 +38,34 @@ locals { "umount /mnt" ] + ignition_config = jsonencode({ + ignition = { + version = "3.0.0" + } + passwd = { + users = [{ + name = "root" + sshAuthorizedKeys = concat([local.ssh_public_key], var.additional_public_keys) + }] + } + storage = { + files = [ + { + path = "/etc/sysconfig/network/ifcfg-eth1" + mode = 420 + overwrite = true + contents = { "source" = "data:,BOOTPROTO%3D%27dhcp%27%0ASTARTMODE%3D%27auto%27" } + }, + { + path = "/etc/ssh/sshd_config.d/kube-hetzner.conf" + mode = 420 + overwrite = true + contents = { "source" = "data:,PasswordAuthentication%20no%0AX11Forwarding%20no%0AMaxAuthTries%202%0AAllowTcpForwarding%20no%0AAllowAgentForwarding%20no%0AAuthorizedKeysFile%20.ssh%2Fauthorized_keys" } + } + ] + } + }) + combustion_script = <