From 240695e8260e5527d30ef80665004e64dcbfe820 Mon Sep 17 00:00:00 2001
From: Simon Lauger <simon@lauger.de>
Date: Sat, 27 Feb 2021 23:27:10 +0100
Subject: [PATCH] fix: add cloudflare resolvers

---
 terraform/modules/hcloud_coreos/ignition.tf       |  1 +
 .../modules/hcloud_coreos/templates/ignition.ign  | 15 +++++++++++++++
 .../modules/hcloud_coreos/templates/resolv.conf   |  3 +++
 3 files changed, 19 insertions(+)
 create mode 100644 terraform/modules/hcloud_coreos/templates/resolv.conf

diff --git a/terraform/modules/hcloud_coreos/ignition.tf b/terraform/modules/hcloud_coreos/ignition.tf
index 6bfdcb3..b59dccc 100644
--- a/terraform/modules/hcloud_coreos/ignition.tf
+++ b/terraform/modules/hcloud_coreos/ignition.tf
@@ -3,6 +3,7 @@ data "template_file" "ignition_config" {
   vars = {
     hostname         = "${format("${var.name}%02d", count.index + 1)}.${var.dns_domain}"
     hostname_b64     = base64encode("${format("${var.name}%02d", count.index + 1)}.${var.dns_domain}")
+    resolvconf_b64   = base64encode(file("${path.module}/templates/resolv.conf"))
     ignition_url     = var.ignition_url
     ignition_version = var.ignition_version
     ignition_cacert  = var.ignition_cacert
diff --git a/terraform/modules/hcloud_coreos/templates/ignition.ign b/terraform/modules/hcloud_coreos/templates/ignition.ign
index b9d31a1..79a4452 100644
--- a/terraform/modules/hcloud_coreos/templates/ignition.ign
+++ b/terraform/modules/hcloud_coreos/templates/ignition.ign
@@ -37,6 +37,21 @@
       }
     ]
   },
+  "storage": {
+    "files": [
+      {
+        "filesystem": "root",
+        "group": {},
+        "path": "/etc/resolv.conf",
+        "user": {},
+        "contents": {
+          "source": "data:text/plain;charset=utf-8;base64,${resolvconf_b64}",
+          "verification": {}
+        },
+        "mode": 420
+      }
+    ]
+  },
   "systemd": {
     "units": [
       {
diff --git a/terraform/modules/hcloud_coreos/templates/resolv.conf b/terraform/modules/hcloud_coreos/templates/resolv.conf
new file mode 100644
index 0000000..f94c004
--- /dev/null
+++ b/terraform/modules/hcloud_coreos/templates/resolv.conf
@@ -0,0 +1,3 @@
+# Managed via Terraform
+nameserver 1.1.1.1
+nameserver 1.0.0.1
-- 
GitLab