Skip to content

Commit 2b90756

Browse files
authored
Merge pull request #380 from jpartlow/pe-36580-add-r10k-known-hosts
(PE-36580) Add r10k_known_hosts to install plan
2 parents 714106a + 9edf544 commit 2b90756

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

REFERENCE.md

+27
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
### Data types
3939

40+
* [`Peadm::Known_hosts`](#Peadm--Known_hosts)
4041
* [`Peadm::Ldap_config`](#Peadm--Ldap_config)
4142
* [`Peadm::Pe_version`](#Peadm--Pe_version)
4243
* [`Peadm::Pem`](#Peadm--Pem)
@@ -776,6 +777,23 @@ Data type: `TargetSpec`
776777

777778
## Data types
778779

780+
### <a name="Peadm--Known_hosts"></a>`Peadm::Known_hosts`
781+
782+
The Peadm::Known_hosts data type.
783+
784+
Alias of
785+
786+
```puppet
787+
Array[Struct[
788+
'title' => Optional[String[1]],
789+
'ensure' => Optional[Enum['present','absent']],
790+
'name' => String[1],
791+
'type' => String[1],
792+
'key' => String[1],
793+
'host_aliases' => Optional[Variant[String[1],Array[String[1]]]],
794+
]]
795+
```
796+
779797
### <a name="Peadm--Ldap_config"></a>`Peadm::Ldap_config`
780798

781799
The Peadm::Ldap_config data type.
@@ -1548,6 +1566,7 @@ The following parameters are available in the `peadm::install` plan:
15481566
* [`r10k_remote`](#-peadm--install--r10k_remote)
15491567
* [`r10k_private_key_file`](#-peadm--install--r10k_private_key_file)
15501568
* [`r10k_private_key_content`](#-peadm--install--r10k_private_key_content)
1569+
* [`r10k_known_hosts`](#-peadm--install--r10k_known_hosts)
15511570
* [`deploy_environment`](#-peadm--install--deploy_environment)
15521571
* [`license_key_file`](#-peadm--install--license_key_file)
15531572
* [`license_key_content`](#-peadm--install--license_key_content)
@@ -1714,6 +1733,14 @@ Data type: `Optional[Peadm::Pem]`
17141733

17151734

17161735

1736+
Default value: `undef`
1737+
1738+
##### <a name="-peadm--install--r10k_known_hosts"></a>`r10k_known_hosts`
1739+
1740+
Data type: `Optional[Peadm::Known_hosts]`
1741+
1742+
1743+
17171744
Default value: `undef`
17181745

17191746
##### <a name="-peadm--install--deploy_environment"></a>`deploy_environment`

plans/install.pp

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
Optional[String] $r10k_remote = undef,
5454
Optional[String] $r10k_private_key_file = undef,
5555
Optional[Peadm::Pem] $r10k_private_key_content = undef,
56+
Optional[Peadm::Known_hosts] $r10k_known_hosts = undef,
5657
Optional[String] $deploy_environment = undef,
5758

5859
# License Key
@@ -94,6 +95,7 @@
9495
r10k_remote => $r10k_remote,
9596
r10k_private_key_file => $r10k_private_key_file,
9697
r10k_private_key_content => $r10k_private_key_content,
98+
r10k_known_hosts => $r10k_known_hosts,
9799

98100
# License Key
99101
license_key_file => $license_key_file,

plans/subplans/install.pp

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
# over to the primary at /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa
1212
# If the file does not exist the value will simply be supplied to the primary
1313
#
14+
# @param r10k_known_hosts
15+
# Puppet Enterprise 2023.3+ requires host key verification for the
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. Please refer to the Puppet Enterprise 2023.3+ Configure Code
20+
# Manager documentation for further details.
21+
#
1422
# @param license_key_file
1523
# The license key to use with Puppet Enterprise. If this is a local file it
1624
# will be copied over to the MoM at /etc/puppetlabs/license.key
@@ -50,6 +58,7 @@
5058
Optional[String] $r10k_remote = undef,
5159
Optional[String] $r10k_private_key_file = undef,
5260
Optional[Peadm::Pem] $r10k_private_key_content = undef,
61+
Optional[Peadm::Known_hosts] $r10k_known_hosts = undef,
5362

5463
# License key
5564
Optional[String] $license_key_file = undef,
@@ -125,7 +134,7 @@
125134
# either be undef or else the key content to write.
126135
$r10k_private_key = peadm::file_or_content('r10k_private_key', $r10k_private_key_file, $r10k_private_key_content)
127136

128-
# Same for license key
137+
# Process user input for license key (same process as for r10k private key above).
129138
$license_key = peadm::file_or_content('license_key', $license_key_file, $license_key_content)
130139

131140
$precheck_results = run_task('peadm::precheck', $all_targets)
@@ -170,6 +179,7 @@
170179
undef => undef,
171180
default => '/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa',
172181
},
182+
'puppet_enterprise::profile::master::r10k_known_hosts' => $r10k_known_hosts,
173183
} + $puppetdb_database_temp_config + $pe_conf_data)
174184

175185
$primary_postgresql_pe_conf = peadm::generate_pe_conf({

spec/plans/subplans/install_spec.rb

+35-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Include the BoltSpec library functions
55
include BoltSpec::Plans
66

7-
it 'minimum variables to run' do
7+
before(:each) do
88
allow_any_task
99
allow_any_plan
1010
allow_any_command
@@ -35,7 +35,9 @@
3535
# rubocop:enable AnyInstance
3636
## </🤮>
3737
##########
38+
end
3839

40+
it 'minimum variables to run' do
3941
params = {
4042
'primary_host' => 'primary',
4143
'console_password' => 'puppetlabs',
@@ -44,4 +46,36 @@
4446

4547
expect(run_plan('peadm::subplans::install', params)).to be_ok
4648
end
49+
50+
it 'installs 2023.2 without r10k_known_hosts' do
51+
params = {
52+
'primary_host' => 'primary',
53+
'console_password' => 'puppetlabs',
54+
'version' => '2023.2.0',
55+
'r10k_remote' => '[email protected]:puppetlabs/nothing',
56+
'r10k_private_key_content' => '-----BEGINfoo',
57+
}
58+
59+
expect(run_plan('peadm::subplans::install', params)).to be_ok
60+
end
61+
62+
it 'installs 2023.3+ with r10k_private_key and r10k_known_hosts' 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+
'r10k_known_hosts' => [
70+
{
71+
'name' => 'test',
72+
'type' => 'key-type',
73+
'key' => 'abcdef',
74+
},
75+
],
76+
'permit_unsafe_versions' => true,
77+
}
78+
79+
expect(run_plan('peadm::subplans::install', params)).to be_ok
80+
end
4781
end

types/known_hosts.pp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type Peadm::Known_hosts = Array[
2+
Struct[
3+
'title' => Optional[String[1]],
4+
'ensure' => Optional[Enum['present','absent']],
5+
'name' => String[1],
6+
'type' => String[1],
7+
'key' => String[1],
8+
'host_aliases' => Optional[Variant[String[1],Array[String[1]]]],
9+
]
10+
]

0 commit comments

Comments
 (0)