mirror of
https://github.com/outbackdingo/terraform-render-bootstrap.git
synced 2026-01-27 18:20:40 +00:00
* Adopt Terrform v0.12 type and templatefile function features to replace the use of terraform-provider-template's `template_dir` * Use of `for_each` to write local assets requires that consumers use Terraform v0.12.6+ (action required) * Continue use of `template_file` as its quite common. In future, we may replace it as well. * Remove outputs `id` and `content_hash` (no longer used) Background: * `template_dir` was added to `terraform-provider-template` to add support for template directory rendering in CoreOS Tectonic Kubernetes distribution (~2017) * Terraform v0.12 introduced a native `templatefile` function and v0.12.6 introduced native `for_each` support (July 2019) that makes it possible to replace `template_dir` usage
77 lines
2.6 KiB
HCL
77 lines
2.6 KiB
HCL
# Assets generated only when certain options are chosen
|
|
|
|
locals {
|
|
# flannel manifests (manifest.yaml => content)
|
|
flannel_manifests = {
|
|
for name in fileset("${path.module}/resources/flannel", "*.yaml"):
|
|
"manifests-networking/${name}" => templatefile(
|
|
"${path.module}/resources/flannel/${name}",
|
|
{
|
|
flannel_image = var.container_images["flannel"]
|
|
flannel_cni_image = var.container_images["flannel_cni"]
|
|
pod_cidr = var.pod_cidr
|
|
}
|
|
)
|
|
if var.networking == "flannel"
|
|
}
|
|
|
|
# calico manifests (manifest.yaml => content)
|
|
calico_manifests = {
|
|
for name in fileset("${path.module}/resources/calico", "*.yaml"):
|
|
"manifests-networking/${name}" => templatefile(
|
|
"${path.module}/resources/calico/${name}",
|
|
{
|
|
calico_image = var.container_images["calico"]
|
|
calico_cni_image = var.container_images["calico_cni"]
|
|
network_mtu = var.network_mtu
|
|
network_encapsulation = indent(2, var.network_encapsulation == "vxlan" ? "vxlanMode: Always" : "ipipMode: Always")
|
|
ipip_enabled = var.network_encapsulation == "ipip" ? true : false
|
|
ipip_readiness = var.network_encapsulation == "ipip" ? indent(16, "- --bird-ready") : ""
|
|
vxlan_enabled = var.network_encapsulation == "vxlan" ? true : false
|
|
network_ip_autodetection_method = var.network_ip_autodetection_method
|
|
pod_cidr = var.pod_cidr
|
|
enable_reporting = var.enable_reporting
|
|
}
|
|
)
|
|
if var.networking == "calico"
|
|
}
|
|
|
|
# kube-router manifests (manifest.yaml => content)
|
|
kube_router_manifests = {
|
|
for name in fileset("${path.module}/resources/kube-router", "*.yaml"):
|
|
"manifests-networking/${name}" => templatefile(
|
|
"${path.module}/resources/kube-router/${name}",
|
|
{
|
|
kube_router_image = var.container_images["kube_router"]
|
|
flannel_cni_image = var.container_images["flannel_cni"]
|
|
network_mtu = var.network_mtu
|
|
}
|
|
)
|
|
if var.networking == "kube-router"
|
|
}
|
|
}
|
|
|
|
# flannel manifests
|
|
resource "local_file" "flannel-manifests" {
|
|
for_each = local.flannel_manifests
|
|
|
|
filename = "${var.asset_dir}/${each.key}"
|
|
content = each.value
|
|
}
|
|
|
|
# Calico manifests
|
|
resource "local_file" "calico-manifests" {
|
|
for_each = local.calico_manifests
|
|
|
|
filename = "${var.asset_dir}/${each.key}"
|
|
content = each.value
|
|
}
|
|
|
|
# kube-router manifests
|
|
resource "local_file" "kube-router-manifests" {
|
|
for_each = local.kube_router_manifests
|
|
|
|
filename = "${var.asset_dir}/${each.key}"
|
|
content = each.value
|
|
}
|