Skip to content

Commit 5fff577

Browse files
committed
Fixes usage of the validate_sshd_file parameter
* Added configuration directly on the server class * Previous usage used false instead of true * Adds test to fix the change
1 parent 08342b9 commit 5fff577

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

manifests/init.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
$users_client_options = {},
77
$version = 'present',
88
$storeconfigs_enabled = true,
9-
$server_validate_config = false
9+
$validate_sshd_file = $::ssh::params::validate_sshd_file,
1010
) inherits ssh::params {
1111

1212
validate_hash($server_options)
1313
validate_hash($server_match_block)
1414
validate_hash($client_options)
1515
validate_hash($users_client_options)
1616
validate_bool($storeconfigs_enabled)
17-
validate_bool($server_validate_config)
17+
validate_bool($validate_sshd_file)
1818

1919
# Merge hashes from multiple layer of hierarchy in hiera
2020
$hiera_server_options = hiera_hash("${module_name}::server_options", undef)
@@ -50,7 +50,7 @@
5050
ensure => $version,
5151
storeconfigs_enabled => $storeconfigs_enabled,
5252
options => $fin_server_options,
53-
validate_config => $server_validate_config,
53+
validate_sshd_file => $validate_sshd_file,
5454
}
5555

5656
class { '::ssh::client':

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
}
199199
}
200200

201+
$validate_sshd_file = false
201202
$user_ssh_directory_default_mode = '0700'
202203
$user_ssh_config_default_mode = '0600'
203204
$collect_enabled = true # Collect sshkey resources

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$ensure = present,
33
$storeconfigs_enabled = true,
44
$options = {},
5-
$validate_config = true
5+
$validate_sshd_file = false,
66
) inherits ssh::params {
77

88
# Merge hashes from multiple layer of hierarchy in hiera

manifests/server/config.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class ssh::server::config {
22

3-
case $ssh::server::validate_config {
4-
false: {
3+
case $ssh::server::validate_sshd_file {
4+
true: {
55
$sshd_validate_cmd = '/usr/sbin/sshd -tf %'
66
}
77
default: {

spec/classes/init_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,39 @@
2525
it do
2626
should contain_class('ssh::server')
2727
end
28+
it do
29+
should contain_concat('/etc/ssh/sshd_config').with_validate_cmd(nil)
30+
end
31+
32+
context 'On Debian with the validate_sshd_file setting' do
33+
let :facts do
34+
{
35+
osfamily: 'Debian',
36+
interfaces: 'eth0',
37+
ipaddress_eth0: '192.168.1.1',
38+
ipaddress6_eth0: '::1',
39+
concat_basedir: '/tmp',
40+
puppetversion: '3.7.0',
41+
sshdsakey: 'AAAAB3NzaC1kc3MAAACBAODCvvUUnv2imW4cfuLBWVJTLMzds89MtCUXGl3+7Gza5QYJmp7GSkKBnV8+7XI+JAmjv0RKQM1RAn7mV5UplRTtg3CYbeNkX4IakZmNJLTdL4vUyIehhaxBobpOtBaJfFewCJE1plIaWvoWfEDrShcjIUbUbJMfR8YWweIIqp9bAAAAFQCr8+KRfOUZbS9Dz1t15A/Owl61VQAAAIBr/7hNPCvjzAl5+rde6jUR5k20pxAE+z2wsaZxlhrs6ZhhplyCKIXKq4rCx4QuFVPh/c+WJRPO56iH/rSh5Y5cpT1LUk66wNJcOBPprjvDEHfQUHUmfYXzNJ2BHkRL78lfzQr52YyowV6dHfktv0VsIctm13KcMr2KQygZtV6EqgAAAIEAjNC4PRdzYpWfxu268CJDpexlhBwIkIx+ovEibtYeke55qAQcF9UWko4A1c8Wf4nLLxlQYCf501Bt5lb6GmZd0xfpg27fPIfzZPL8o+E756D3ZcNXUaLj4HPRKnwNcdAtChL2jESH3fm8PyNwBI7tV6IOjmOGpyQKtmJq3IyNgms=',
42+
sshrsakey: 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDzA57hAMwz6pywCgxNUcloWeNMvBo2PDPxK2RCegst+9tYaf4S3shnM9a1j2PGBoeRXTuUG6mYB32fJm6/37UUUJA4lT+8CZ3hNnDZU9aitpukkKon7RIlvY1PWO8wT4A5mEa0hfdQg6Um8KZZUs+jrB+8zMJO/X0fmleY54r/JKrP3hNcpaJpTUVQEvMmKacW7nYez/PvWKAz8d02uAOXuauGKhZ9K2AHYKlQFqJ4S1jLiduoGFWxFQ2vQybbN/O0PQQU7EZlHIjSzwoowZLzlxCKCZcKnoDsbGCtYHArbjxTb+m5e7nvsamz7TXLoY90Srmc5QGMxrLUlSvkYsm5',
43+
sshecdsakey: 'AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFDrof0LPA0hGuwODy+5uTynV7rgPJspvZo2TzykBu5mSANJvdL1z5/JS3x16/c/cDjx2lfEkRoVDnon4/NjKEM=',
44+
sshed25519key: '',
45+
id: 'root',
46+
is_pe: false,
47+
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'
48+
}
49+
end
50+
let :params do
51+
{
52+
validate_sshd_file: true
53+
}
54+
end
55+
it do
56+
should contain_class('ssh::client')
57+
end
58+
it do
59+
should contain_concat('/etc/ssh/sshd_config').with_validate_cmd('/usr/sbin/sshd -tf %')
60+
end
61+
end
2862
end
2963
end

0 commit comments

Comments
 (0)