diff --git a/README.md b/README.md index 6d04fd2..3bbb4c1 100644 --- a/README.md +++ b/README.md @@ -346,9 +346,9 @@ Specify that the init script has a restart command. Valid values are 'true' and service_hasstatus ----------------- -Declare whether the service's init script has a functional status command. Valid values are 'true' and 'false' +Boolean to declare whether the service's init script has a functional status command. -- *Default*: 'true' +- *Default*: 'USE_DEFAULTS' ssh_key_ensure -------------- diff --git a/manifests/init.pp b/manifests/init.pp index 6f06a7c..e0063c5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -52,7 +52,7 @@ class ssh ( $service_name = 'USE_DEFAULTS', $service_enable = 'true', $service_hasrestart = 'true', - $service_hasstatus = 'true', + $service_hasstatus = 'USE_DEFAULTS', $ssh_key_ensure = 'present', $ssh_key_type = 'ssh-rsa', $keys = undef, @@ -78,7 +78,8 @@ class ssh ( $default_sshd_gssapikeyexchange = undef $default_sshd_pamauthenticationviakbdint = undef $default_sshd_gssapicleanupcredentials = 'yes' - $default_sshd_acceptenv = true + $default_sshd_acceptenv = true + $default_service_hasstatus = true } 'Suse': { $default_packages = 'openssh' @@ -96,6 +97,7 @@ class ssh ( $default_sshd_pamauthenticationviakbdint = undef $default_sshd_gssapicleanupcredentials = 'yes' $default_sshd_acceptenv = true + $default_service_hasstatus = true case $::architecture { 'x86_64': { $default_sshd_config_subsystem_sftp = '/usr/lib64/ssh/sftp-server' @@ -126,6 +128,7 @@ class ssh ( $default_sshd_pamauthenticationviakbdint = undef $default_sshd_gssapicleanupcredentials = 'yes' $default_sshd_acceptenv = true + $default_service_hasstatus = true } 'Solaris': { $default_packages = ['SUNWsshcu', @@ -149,10 +152,12 @@ class ssh ( $default_sshd_acceptenv = false case $::kernelrelease { '5.10','5.11': { - $default_service_name = 'ssh' + $default_service_name = 'ssh' + $default_service_hasstatus = true } '5.9' : { - $default_service_name = 'sshd' + $default_service_name = 'sshd' + $default_service_hasstatus = false } default: { fail('ssh module supports Solaris kernel release 5.9, 5.10 and 5.11.') @@ -289,6 +294,23 @@ class ssh ( } } + if $service_hasstatus == 'USE_DEFAULTS' { + $service_hasstatus_real = $default_service_hasstatus + } else { + case type($service_hasstatus) { + 'string': { + validate_re($service_hasstatus, '^(true|false)$', "ssh::service_hasstatus may be either 'true' or 'false' and is set to <${service_hasstatus}>.") + $service_hasstatus_real = str2bool($service_hasstatus) + } + 'boolean': { + $service_hasstatus_real = $service_hasstatus + } + default: { + fail('ssh::service_hasstatus type must be true or false.') + } + } + } + # validate params if $ssh_config_hash_known_hosts_real != undef { validate_re($ssh_config_hash_known_hosts_real, '^(yes|no)$', "ssh::ssh_config_hash_known_hosts may be either 'yes' or 'no' and is set to <${ssh_config_hash_known_hosts_real}>.") @@ -454,7 +476,7 @@ class ssh ( name => $service_name_real, enable => $service_enable, hasrestart => $service_hasrestart, - hasstatus => $service_hasstatus, + hasstatus => $service_hasstatus_real, subscribe => File['sshd_config'], } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index f7aa0ab..e4b3194 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -367,7 +367,7 @@ describe 'ssh' do 'name' => 'sshd', 'enable' => 'true', 'hasrestart' => 'true', - 'hasstatus' => 'true', + 'hasstatus' => 'false', 'subscribe' => 'File[sshd_config]', }) }