mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-25 17:39:33 +01:00
Combine bare-metal CLC snippets maps into one map
This commit is contained in:
parent
4e7dfc115d
commit
90c4a7483d
@ -126,7 +126,7 @@ data "ct_config" "controller-ignitions" {
|
||||
content = "${element(data.template_file.controller-configs.*.rendered, count.index)}"
|
||||
pretty_print = false
|
||||
# Must use direct lookup. Cannot use lookup(map, key) since it only works for flat maps
|
||||
snippets = ["${local.controller_clc_map[element(var.controller_names, count.index)]}"]
|
||||
snippets = ["${local.clc_map[element(var.controller_names, count.index)]}"]
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ data "ct_config" "worker-ignitions" {
|
||||
content = "${element(data.template_file.worker-configs.*.rendered, count.index)}"
|
||||
pretty_print = false
|
||||
# Must use direct lookup. Cannot use lookup(map, key) since it only works for flat maps
|
||||
snippets = ["${local.worker_clc_map[element(var.worker_names, count.index)]}"]
|
||||
snippets = ["${local.clc_map[element(var.worker_names, count.index)]}"]
|
||||
}
|
||||
|
||||
data "template_file" "worker-configs" {
|
||||
@ -182,23 +182,15 @@ data "template_file" "worker-configs" {
|
||||
|
||||
locals {
|
||||
# Hack to workaround https://github.com/hashicorp/terraform/issues/17251
|
||||
# Default CLC snippets map every worker to list("\n") so all lookups succeed
|
||||
controller_clc_default = "${zipmap(var.controller_names, chunklist(data.template_file.controller-clc-snippets.*.rendered, 1))}"
|
||||
worker_clc_default = "${zipmap(var.worker_names, chunklist(data.template_file.worker-clc-snippets.*.rendered, 1))}"
|
||||
# Default Container Linux config snippets map every node names to list("\n") so
|
||||
# all lookups succeed
|
||||
clc_defaults = "${zipmap(concat(var.controller_names, var.worker_names), chunklist(data.template_file.clc-default-snippets.*.rendered, 1))}"
|
||||
# Union of the default and user specific snippets, later overrides prior.
|
||||
controller_clc_map = "${merge(local.controller_clc_default, var.controller_clc_snippets)}"
|
||||
worker_clc_map = "${merge(local.worker_clc_default, var.worker_clc_snippets)}"
|
||||
clc_map = "${merge(local.clc_defaults, var.clc_snippets)}"
|
||||
}
|
||||
|
||||
// Horrible hack to generate a Terraform list of controller count length
|
||||
data "template_file" "controller-clc-snippets" {
|
||||
count = "${length(var.controller_names)}"
|
||||
// Horrible hack to generate a Terraform list of node count length
|
||||
data "template_file" "clc-default-snippets" {
|
||||
count = "${length(var.controller_names) + length(var.worker_names)}"
|
||||
template = "\n"
|
||||
}
|
||||
|
||||
// Horrible hack to generate a Terraform list of worker count length
|
||||
data "template_file" "worker-clc-snippets" {
|
||||
count = "${length(var.worker_names)}"
|
||||
template = "\n"
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,6 @@ variable "controller_domains" {
|
||||
description = "Ordered list of controller FQDNs (e.g. [node1.example.com])"
|
||||
}
|
||||
|
||||
variable "controller_clc_snippets" {
|
||||
type = "map"
|
||||
description = "Map from controller names to a lists of Container Linux Config snippets"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "worker_names" {
|
||||
type = "list"
|
||||
description = "Ordered list of worker names (e.g. [node2, node3])"
|
||||
@ -59,9 +53,9 @@ variable "worker_domains" {
|
||||
description = "Ordered list of worker FQDNs (e.g. [node2.example.com, node3.example.com])"
|
||||
}
|
||||
|
||||
variable "worker_clc_snippets" {
|
||||
variable "clc_snippets" {
|
||||
type = "map"
|
||||
description = "Map from worker names to a lists of Container Linux Config snippets"
|
||||
description = "Map from machine names to lists of Container Linux Config snippets"
|
||||
default = {}
|
||||
}
|
||||
|
||||
|
@ -89,16 +89,17 @@ module "digital-ocean-nemo" {
|
||||
}
|
||||
```
|
||||
|
||||
Bare-Metal clusters allow different Container Linux snippets to be used for each node (since hardware may be heterogeneous). Define the optional `controller_clc_snippets` and `worker_clc_snippets` map variables using controller or worker keys.
|
||||
Bare-Metal clusters allow different Container Linux snippets to be used for each node (since hardware may be heterogeneous). Populate the optional `clc_snippets` map variable with any controller or worker name keys and lists of snippets.
|
||||
|
||||
```
|
||||
module "bare-metal-mercury" {
|
||||
...
|
||||
controller_names = ["node1"]
|
||||
worker_names = [
|
||||
"node2",
|
||||
"node3",
|
||||
]
|
||||
worker_clc_snippets = {
|
||||
clc_snippets = {
|
||||
"node2" = [
|
||||
"${file("./units/hello.yaml")}"
|
||||
]
|
||||
|
@ -381,8 +381,7 @@ Check the [variables.tf](https://github.com/poseidon/typhoon/blob/master/bare-me
|
||||
| install_disk | Disk device where Container Linux should be installed | "/dev/sda" | "/dev/sdb" |
|
||||
| networking | Choice of networking provider | "calico" | "calico" or "flannel" |
|
||||
| network_mtu | CNI interface MTU (calico-only) | 1480 | - |
|
||||
| controller_clc_snippets | Map from controller names to lists of Container Linux Config snippets | {} | |
|
||||
| worker_clc_snippets | Map from worker names to lists of Container Linux Config snippets | {} | |
|
||||
| clc_snippets | Map from machine names to lists of Container Linux Config snippets | {} | [example](/advanced/customization/#usage) |
|
||||
| network_ip_autodetection_method | Method to detect host IPv4 address (calico-only) | first-found | can-reach=10.0.0.1 |
|
||||
| pod_cidr | CIDR IPv4 range to assign to Kubernetes pods | "10.2.0.0/16" | "10.22.0.0/16" |
|
||||
| service_cidr | CIDR IPv4 range to assign to Kubernetes services | "10.3.0.0/16" | "10.3.0.0/24" |
|
||||
|
Loading…
Reference in New Issue
Block a user