Skip to content

Commit 5a37ee5

Browse files
committed
(PE-36580) Remove fail_plan for r10k_known_hosts
Since we aren't testing whether r10k_remote using git@ or ssh:// also has r10k_private_key set, testing for r10k_known_hosts seems like overkill. Removing that plan_fail, and setting r10k_known_hosts directly in the generate_pe_conf call alongside the other r10k parameters. It's true that this parameter only exists in 2023.3+, but peadm::generate_pe_conf() will drop parameters with undef values, and if r10k_known_hosts is explicitly set by mistake by a user on an earlier version than 2023.3, an unmatched parameter in pe.conf hiera is not fatal.
1 parent 85ff769 commit 5a37ee5

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

plans/subplans/install.pp

+6-18
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
#
1414
# @param r10k_known_hosts
1515
# Puppet Enterprise 2023.3+ requires host key verification for the
16-
# r10k_remote host. When setting \$r10k_private_key, you must also provide
17-
# \$r10k_known_hosts information in the form of an array of hashes with
18-
# 'name', 'type' and 'key' information for hostname, key-type and public key.
16+
# r10k_remote host when using ssh. When setting \$r10k_private_key, you must
17+
# also provide \$r10k_known_hosts information in the form of an array of
18+
# hashes with 'name', 'type' and 'key' information for hostname, key-type and
19+
# public key.
1920
#
2021
# @param license_key_file
2122
# The license key to use with Puppet Enterprise. If this is a local file it
@@ -132,20 +133,6 @@
132133
# either be undef or else the key content to write.
133134
$r10k_private_key = peadm::file_or_content('r10k_private_key', $r10k_private_key_file, $r10k_private_key_content)
134135

135-
# Determine whether r10k_known_hosts is required and has been provided.
136-
$is_pe_2023_3_or_greater = (versioncmp($version, '2023.3.0') >= 0)
137-
if (($is_pe_2023_3_or_greater) and
138-
($r10k_private_key =~ NotUndef) and
139-
($r10k_known_hosts =~ Undef)) {
140-
fail_plan("In Puppet Enterprise 2023.3+ r10k 4.0 requires host key verification for the r10k_remote host. When setting \$r10k_private_key, you must also provide \$r10k_known_hosts information in the form of an array of hashes with 'name', 'type' and 'key' information for hostname, key-type and public key. Puppet Enterprise version: ${version}, r10k_known_hosts: ${r10k_known_hosts}")
141-
}
142-
$r10k_known_hosts_config = $r10k_known_hosts ? {
143-
undef => {},
144-
default => {
145-
'puppet_enterprise::profile::master::r10k_known_hosts' => $r10k_known_hosts,
146-
},
147-
}
148-
149136
# Process user input for license key (same process as for r10k private key above).
150137
$license_key = peadm::file_or_content('license_key', $license_key_file, $license_key_content)
151138

@@ -191,7 +178,8 @@
191178
undef => undef,
192179
default => '/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa',
193180
},
194-
} + $r10k_known_hosts_config + $puppetdb_database_temp_config + $pe_conf_data)
181+
'puppet_enterprise::profile::master::r10k_known_hosts' => $r10k_known_hosts,
182+
} + $puppetdb_database_temp_config + $pe_conf_data)
195183

196184
$primary_postgresql_pe_conf = peadm::generate_pe_conf({
197185
'console_admin_password' => 'not used',

spec/plans/subplans/install_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,6 @@
5959
expect(run_plan('peadm::subplans::install', params)).to be_ok
6060
end
6161

62-
it 'fails if 2023.3+ and r10k_private_key set but r10k_known_hosts not set' do
63-
params = {
64-
'primary_host' => 'primary',
65-
'console_password' => 'puppetlabs',
66-
'version' => '2023.3.0',
67-
'r10k_remote' => '[email protected]:puppetlabs/nothing',
68-
'r10k_private_key_content' => '-----BEGINfoo',
69-
'permit_unsafe_versions' => true,
70-
}
71-
72-
result = run_plan('peadm::subplans::install', params)
73-
expect(result).not_to be_ok
74-
expect(result.value.message).to match(%r{Puppet Enterprise 2023\.3\+ .*requires host key verification})
75-
end
76-
7762
it 'installs 2023.3+ with r10k_private_key and r10k_known_hosts' do
7863
params = {
7964
'primary_host' => 'primary',

0 commit comments

Comments
 (0)