From 634deaf92e1552654550674f527afa041c6be7a0 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Thu, 3 Aug 2023 14:12:57 +0200 Subject: [PATCH] Adding install_snippets support. During the "real" first boot (install boot), we need tu run butane config to manipulate disks, so we add install_snippets variable to do so. This snippets are added to the install.yaml butane configuration --- bare-metal/flatcar-linux/kubernetes/profiles.tf | 1 + bare-metal/flatcar-linux/kubernetes/variables.tf | 6 ++++++ bare-metal/flatcar-linux/kubernetes/worker/matchbox.tf | 1 + bare-metal/flatcar-linux/kubernetes/worker/variables.tf | 6 ++++++ bare-metal/flatcar-linux/kubernetes/workers.tf | 1 + 5 files changed, 15 insertions(+) diff --git a/bare-metal/flatcar-linux/kubernetes/profiles.tf b/bare-metal/flatcar-linux/kubernetes/profiles.tf index 1537a408..7fb549e0 100644 --- a/bare-metal/flatcar-linux/kubernetes/profiles.tf +++ b/bare-metal/flatcar-linux/kubernetes/profiles.tf @@ -60,6 +60,7 @@ data "ct_config" "install" { baseurl_flag = var.cached_install ? "-b ${var.matchbox_http_endpoint}/assets/flatcar" : "" }) strict = true + install_snippets = lookup(var.install_snippets, var.controllers.*.name[count.index], []) } # Match each controller by MAC diff --git a/bare-metal/flatcar-linux/kubernetes/variables.tf b/bare-metal/flatcar-linux/kubernetes/variables.tf index 2f379887..6d3f13f2 100644 --- a/bare-metal/flatcar-linux/kubernetes/variables.tf +++ b/bare-metal/flatcar-linux/kubernetes/variables.tf @@ -61,6 +61,12 @@ variable "snippets" { default = {} } +variable "install_snippets" { + type = map(list(string)) + description = "Map from machine names to lists of Container Linux Config snippets to run during install phase" + default = {} +} + variable "worker_node_labels" { type = map(list(string)) description = "Map from worker names to lists of initial node labels" diff --git a/bare-metal/flatcar-linux/kubernetes/worker/matchbox.tf b/bare-metal/flatcar-linux/kubernetes/worker/matchbox.tf index f0800fe9..854c2cee 100644 --- a/bare-metal/flatcar-linux/kubernetes/worker/matchbox.tf +++ b/bare-metal/flatcar-linux/kubernetes/worker/matchbox.tf @@ -55,6 +55,7 @@ data "ct_config" "install" { baseurl_flag = var.cached_install ? "-b ${var.matchbox_http_endpoint}/assets/flatcar" : "" }) strict = true + snippets = var.install_snippets } # Match a worker to a profile by MAC diff --git a/bare-metal/flatcar-linux/kubernetes/worker/variables.tf b/bare-metal/flatcar-linux/kubernetes/worker/variables.tf index 98d3534d..f535f93e 100644 --- a/bare-metal/flatcar-linux/kubernetes/worker/variables.tf +++ b/bare-metal/flatcar-linux/kubernetes/worker/variables.tf @@ -60,6 +60,12 @@ variable "snippets" { default = [] } +variable "install_snippets" { + type = list(string) + description = "List of Butane snippets to run with the install command" + default = [] +} + variable "node_labels" { type = list(string) description = "List of initial node labels" diff --git a/bare-metal/flatcar-linux/kubernetes/workers.tf b/bare-metal/flatcar-linux/kubernetes/workers.tf index e558aec7..0ea4b3fa 100644 --- a/bare-metal/flatcar-linux/kubernetes/workers.tf +++ b/bare-metal/flatcar-linux/kubernetes/workers.tf @@ -22,6 +22,7 @@ module "workers" { node_labels = lookup(var.worker_node_labels, var.workers[count.index].name, []) node_taints = lookup(var.worker_node_taints, var.workers[count.index].name, []) snippets = lookup(var.snippets, var.workers[count.index].name, []) + install_snippets = lookup(var.install_snippets, var.workers[count.index].name, []) # optional download_protocol = var.download_protocol