Skip to content

Commit e4b02a4

Browse files
authored
Merge pull request #72 from puppetlabs/preserve-certnames
Set certnames to target names
2 parents 9b59b32 + 28cc45d commit e4b02a4

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

plans/action/install.pp

+35-24
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@
115115
# the configured hostname, and that all systems return the same platform
116116
$precheck_results.each |$result| {
117117
if $result.target.name != $result['hostname'] {
118-
fail_plan("Hostname / DNS name mismatch: target ${result.target.name} reports '${result['hostname']}'")
118+
warning(@("HEREDOC"))
119+
WARNING: Target name / hostname mismatch: target ${result.target.name} reports ${result['hostname']}
120+
Certificate name will be set to target name. Please ensure target name is correct and resolvable
121+
|-HEREDOC
119122
}
120123
if $result['platform'] != $platform {
121124
fail_plan("Platform mismatch: target ${result.target.name} reports '${result['platform']}; expected ${platform}'")
@@ -148,10 +151,22 @@
148151
'puppet_enterprise::database_host' => $puppetdb_database_replica_target.peadm::target_name(),
149152
} + $pe_conf_data)
150153

151-
# Upload the pe.conf files to the hosts that need them
152-
peadm::file_content_upload($master_pe_conf, '/tmp/pe.conf', $master_target)
153-
peadm::file_content_upload($puppetdb_database_pe_conf, '/tmp/pe.conf', $puppetdb_database_target)
154-
peadm::file_content_upload($puppetdb_database_replica_pe_conf, '/tmp/pe.conf', $puppetdb_database_replica_target)
154+
# Upload the pe.conf files to the hosts that need them, and ensure correctly
155+
# configured certnames. Right now for these hosts we need to do that by
156+
# staging a puppet.conf file.
157+
['master', 'puppetdb_database', 'puppetdb_database_replica'].each |$var| {
158+
$target = getvar("${var}_target")
159+
$pe_conf = getvar("${var}_pe_conf")
160+
161+
peadm::file_content_upload($pe_conf, '/tmp/pe.conf', $target)
162+
run_task('peadm::mkdir_p_file', $target,
163+
path => '/etc/puppetlabs/puppet/puppet.conf',
164+
content => @("HEREDOC"),
165+
[main]
166+
certname = ${target.peadm::target_name()}
167+
| HEREDOC
168+
)
169+
}
155170

156171
# Download the PE tarball and send it to the nodes that need it
157172
$pe_tarball_name = "puppet-enterprise-${version}-${platform}.tar.gz"
@@ -290,31 +305,27 @@
290305
server => $master_target.peadm::target_name(),
291306
install_flags => [
292307
'--puppet-service-ensure', 'stopped',
308+
"main:certname=${master_replica_target.peadm::target_name()}",
293309
"main:dns_alt_names=${dns_alt_names_csv}",
294310
"extension_requests:${pp_application}=puppet/master",
295311
"extension_requests:${pp_cluster}=B",
296312
],
297313
)
298314

299-
run_task('peadm::agent_install', $compiler_a_targets,
300-
server => $master_target.peadm::target_name(),
301-
install_flags => [
302-
'--puppet-service-ensure', 'stopped',
303-
"main:dns_alt_names=${dns_alt_names_csv}",
304-
"extension_requests:${pp_application}=puppet/compiler",
305-
"extension_requests:${pp_cluster}=A",
306-
],
307-
)
308-
309-
run_task('peadm::agent_install', $compiler_b_targets,
310-
server => $master_target.peadm::target_name(),
311-
install_flags => [
312-
'--puppet-service-ensure', 'stopped',
313-
"main:dns_alt_names=${dns_alt_names_csv}",
314-
"extension_requests:${pp_application}=puppet/compiler",
315-
"extension_requests:${pp_cluster}=B",
316-
],
317-
)
315+
['A', 'B'].each |$group| {
316+
getvar("compiler_${group.downcase()}_targets").each |$target| {
317+
run_task('peadm::agent_install', $target,
318+
server => $master_target.peadm::target_name(),
319+
install_flags => [
320+
'--puppet-service-ensure', 'stopped',
321+
"main:certname=${target.peadm::target_name()}",
322+
"main:dns_alt_names=${dns_alt_names_csv}",
323+
"extension_requests:${pp_application}=puppet/compiler",
324+
"extension_requests:${pp_cluster}=${group}",
325+
],
326+
)
327+
}
328+
}
318329

319330
# Ensure certificate requests have been submitted
320331
run_task('peadm::submit_csr', $agent_installer_targets)

0 commit comments

Comments
 (0)