From a0974cc29e06f20108abe316f3ec4d221cac5444 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 15 Dec 2023 15:27:02 +0100 Subject: [PATCH] pass parameter direktly to template --- manifests/server/resources/coredns.pp | 6 ++++-- templates/server/resources/coredns_corefile.epp | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/manifests/server/resources/coredns.pp b/manifests/server/resources/coredns.pp index 581ffad..1c18b62 100644 --- a/manifests/server/resources/coredns.pp +++ b/manifests/server/resources/coredns.pp @@ -12,6 +12,7 @@ # @param kubeconfig The path to the kubeconfig to use for kubectl commands # @param registry The CoreDNS image registry to use # @param template_path The path to the template to use for the CoreDNS ConfigMap +# @param template_variables The variables to use for the CoreDNS ConfigMap template # class k8s::server::resources::coredns ( K8s::Ensure $ensure = $k8s::ensure, @@ -25,7 +26,8 @@ Hash[String,Data] $deployment_config = $k8s::server::resources::coredns_deployment_config, Array[String[1]] $hosts = [], String[1] $template_path = 'k8s/server/resources/coredns_corefile.epp', - Optional[String[1]] $corefile_content = undef + Optional[String[1]] $corefile_content = undef, + Hash[String, Any] $template_variables = { cluster_domain => $cluster_domain }, ) { assert_private() @@ -45,7 +47,7 @@ if $corefile_content { $_corefile_content = $corefile_content } else { - $_corefile_content = epp($template_path) + $_corefile_content = epp($template_path, $template_variables) } kubectl_apply { diff --git a/templates/server/resources/coredns_corefile.epp b/templates/server/resources/coredns_corefile.epp index f0af5ea..25af63e 100644 --- a/templates/server/resources/coredns_corefile.epp +++ b/templates/server/resources/coredns_corefile.epp @@ -1,10 +1,13 @@ +<%- | + Stdlib::Fqdn $cluster_domain, +| -%> .:53 { errors health { lameduck 5s } ready - kubernetes <%= $k8s::server::resources::coredns::cluster_domain %> in-addr.arpa ip6.arpa { + kubernetes <%= $cluster_domain %> in-addr.arpa ip6.arpa { fallthrough in-addr.arpa ip6.arpa } prometheus :9153