From cd63a5bc18839cba59cbb8c9a73eff20f9030e4d Mon Sep 17 00:00:00 2001 From: phaer Date: Mon, 7 Feb 2022 14:43:40 +0100 Subject: [PATCH] re-add agent.conf... ...because it's not worth the necessary overrides/hacks in the base image to remove it. --- agents.tf | 21 ++++++++++++++++++--- templates/agent.conf.tpl | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 templates/agent.conf.tpl diff --git a/agents.tf b/agents.tf index ffba9a5..04bb1e0 100644 --- a/agents.tf +++ b/agents.tf @@ -59,15 +59,30 @@ resource "hcloud_server" "agents" { EOT } - # Generating k3s server config file + + # Generating and uploading the agent.conf file + provisioner "file" { + content = templatefile("${path.module}/templates/agent.conf.tpl", { + server = "https://${local.first_control_plane_network_ip}:6443" + token = random_password.k3s_token.result + }) + destination = "/etc/rancher/k3s/agent.conf" + + connection { + user = "root" + private_key = local.ssh_private_key + agent_identity = local.ssh_identity + host = self.ipv4_address + } + } + + # Generating k3s agent config file provisioner "file" { content = yamlencode({ node-name = self.name - server = "https://${local.first_control_plane_network_ip}:6443" kubelet-arg = "cloud-provider=external" flannel-iface = "eth1" node-ip = local.first_control_plane_network_ip - token = random_password.k3s_token.result }) destination = "/etc/rancher/k3s/config.yaml" diff --git a/templates/agent.conf.tpl b/templates/agent.conf.tpl new file mode 100644 index 0000000..fad0449 --- /dev/null +++ b/templates/agent.conf.tpl @@ -0,0 +1,3 @@ +SERVER_URL="${server}" +NODE_TOKEN="${token}" +AGENT_OPTS=""