Skip to content

Commit 6874f57

Browse files
committed
Move puppet server config out of template
1 parent b71c05b commit 6874f57

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

common/configuration/main.tf

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,19 @@ locals {
9393
software_stack = var.software_stack,
9494
})
9595

96-
puppet_conf = [
97-
{ key = "waitforcert", value = "15s", section = "main" },
98-
{ key = "report", value = "true", section = "main" },
99-
{ key = "postrun_command", value = "/opt/puppetlabs/bin/postrun", section = "main" }
100-
]
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+
)
101109

102110
user_data = {
103111
for key, values in var.inventory : key =>
@@ -112,7 +120,7 @@ locals {
112120
domain_name = var.domain_name
113121
puppetenv_git = var.config_git_url,
114122
puppetenv_rev = var.config_version,
115-
puppetservers = { for host, values in var.inventory : host => try(values.local_ip, "") if contains(values.tags, "puppet") }
123+
puppetservers = local.puppetservers
116124
puppetserver_password = local.puppet_passwd,
117125
puppet_conf = concat(local.puppet_conf, var.puppet_conf, [{ key = "certname", value = key, section = "main" }])
118126
sudoer_username = var.sudoer_username,

common/configuration/puppet.yaml.tftpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ runcmd:
134134
%{ endif ~}
135135
- chgrp puppet /etc/puppetlabs/puppet/csr_attributes.yaml
136136
%{ endif ~}
137-
%{ if length(puppetservers) > 0 ~}
138-
- /opt/puppetlabs/bin/puppet config set server ${keys(puppetservers)[0]}
139-
%{ endif ~}
140137
%{ for conf in puppet_conf ~}
141138
- ${jsonencode(["/opt/puppetlabs/bin/puppet", "config", "set", conf.key, conf.value, "--section", conf.section])}
142139
%{ endfor ~}

0 commit comments

Comments
 (0)