99
1010variable "config_git_url" {}
1111variable "config_version" {}
12+ variable "puppet_conf" {}
1213
1314variable "sudoer_username" {}
1415
@@ -92,6 +93,20 @@ locals {
9293 software_stack = var.software_stack,
9394 })
9495
96+ puppetservers = {
97+ for host , values in var . inventory : host => try (values. local_ip , " " ) if contains (values. tags , " puppet" )
98+ }
99+ puppet_conf = concat (
100+ length (local. puppetservers ) > 0 ? [
101+ { key = " server" , value = keys (local. puppetservers )[0 ], section = " main" }
102+ ] : [],
103+ [
104+ { key = " waitforcert" , value = " 15s" , section = " main" },
105+ { key = " report" , value = " true" , section = " main" },
106+ { key = " postrun_command" , value = " /opt/puppetlabs/bin/postrun" , section = " main" }
107+ ],
108+ )
109+
95110 user_data = {
96111 for key , values in var . inventory : key =>
97112 templatefile (" ${ path . module } /puppet.yaml.tftpl" ,
@@ -105,8 +120,9 @@ locals {
105120 domain_name = var.domain_name
106121 puppetenv_git = var.config_git_url,
107122 puppetenv_rev = var.config_version,
108- puppetservers = { for host , values in var . inventory : host => try (values . local_ip , " " ) if contains (values . tags , " puppet " ) }
123+ puppetservers = local.puppetservers
109124 puppetserver_password = local.puppet_passwd,
125+ puppet_conf = concat (local. puppet_conf , var. puppet_conf , [{ key = " certname" , value = key, section = " main" }])
110126 sudoer_username = var.sudoer_username,
111127 ssh_authorized_keys = local.public_keys
112128 tf_ssh_public_key = chomp (tls_private_key. ssh . public_key_openssh )
0 commit comments