From 988f677ffda2104289e35ee398981f87843f93c3 Mon Sep 17 00:00:00 2001 From: Simon Rondelez Date: Tue, 22 Nov 2022 10:38:44 +0100 Subject: [PATCH] Remove template resource (#41) * Remove template resource * support count --- puppet-userdata/main.tf | 25 +++++++++---------- puppet-userdata/outputs.tf | 2 +- .../{metadata.tpl => metadata.tftpl} | 0 3 files changed, 13 insertions(+), 14 deletions(-) rename puppet-userdata/templates/{metadata.tpl => metadata.tftpl} (100%) diff --git a/puppet-userdata/main.tf b/puppet-userdata/main.tf index 81bd026..d0031f8 100644 --- a/puppet-userdata/main.tf +++ b/puppet-userdata/main.tf @@ -1,14 +1,13 @@ -data "template_file" "metadata_puppet" { - count = var.amount_of_instances - template = file("${path.module}/templates/metadata.tpl") - - vars = { - number = count.index + 1 - environment = var.environment == "production" ? "" : "-${var.environment}" - project = var.project == null ? "" : "-${var.project}" - customer = var.customer - function = var.function - puppetmaster = var.puppetmaster - domain = var.domain - } +locals { + metadatas = [ + for n in range(var.amount_of_instances) : templatefile("${path.module}/templates/metadata.tftpl", { + number = n + environment = var.environment == "production" ? "" : "-${var.environment}" + project = var.project == null ? "" : "-${var.project}" + customer = var.customer + function = var.function + puppetmaster = var.puppetmaster + domain = var.domain + }) + ] } diff --git a/puppet-userdata/outputs.tf b/puppet-userdata/outputs.tf index d2b39a7..8fe50cd 100644 --- a/puppet-userdata/outputs.tf +++ b/puppet-userdata/outputs.tf @@ -1,3 +1,3 @@ output "user_datas" { - value = data.template_file.metadata_puppet.*.rendered + value = local.metadatas } diff --git a/puppet-userdata/templates/metadata.tpl b/puppet-userdata/templates/metadata.tftpl similarity index 100% rename from puppet-userdata/templates/metadata.tpl rename to puppet-userdata/templates/metadata.tftpl