Update hostcertificated to take both Strings and Arrays

This commit is contained in:
David Hollinger 2017-07-24 14:26:57 -05:00
parent 0ac138213e
commit 4cefc65069
3 changed files with 14 additions and 8 deletions

View File

@ -845,7 +845,9 @@ class ssh (
} }
if $sshd_config_hostcertificate_real != undef { if $sshd_config_hostcertificate_real != undef {
validate_array($sshd_config_hostcertificate_real) if is_array($sshd_config_hostcertificate_real) {
validate_array($sshd_config_hostcertificate_real)
}
validate_absolute_path($sshd_config_hostcertificate_real) validate_absolute_path($sshd_config_hostcertificate_real)
} }

View File

@ -1075,7 +1075,7 @@ describe 'sshd_config_print_last_log param' do
end end
context 'with a certificate' do context 'with a certificate' do
let(:params) { { :sshd_config_hostcertificate => ['/etc/ssh/ssh_host_key-cert.pub'] } } let(:params) { { :sshd_config_hostcertificate => '/etc/ssh/ssh_host_key-cert.pub' } }
it { should contain_file('sshd_config').with_content(/^HostCertificate \/etc\/ssh\/ssh_host_key-cert\.pub/) } it { should contain_file('sshd_config').with_content(/^HostCertificate \/etc\/ssh\/ssh_host_key-cert\.pub/) }
end end
@ -1088,12 +1088,14 @@ describe 'sshd_config_print_last_log param' do
end end
context 'with sshd_config_hostcertificate set to invalid value on valid osfamily' do context 'with sshd_config_hostcertificate set to invalid value on valid osfamily' do
let(:params) { { :sshd_config_hostcertificate => 'invalid' } } context 'with string' do
let(:params) { { :sshd_config_hostcertificate => 'invalid' } }
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::PreformattedError,/"invalid" is not an Array/) }.to raise_error(Puppet::Error,/"invalid" is not an absolute path/)
end
end end
end end

View File

@ -263,10 +263,12 @@ Match <%= key %>
<% end -%> <% end -%>
<% end -%> <% end -%>
<% end -%> <% end -%>
<% if @sshd_config_hostcertificate_real -%> <% if @sshd_config_hostcertificate_real.class == Array -%>
<% @sshd_config_hostcertificate_real.each do |cert| -%> <% @sshd_config_hostcertificate_real.each do |cert| -%>
HostCertificate <%= cert %> HostCertificate <%= cert %>
<% end -%> <% end -%>
<% elsif @sshd_config_hostcertificate_real.class == String -%>
HostCertificate <%= @sshd_config_hostcertificate_real %>
<% end -%> <% end -%>
<% if @sshd_config_trustedusercakeys_real -%> <% if @sshd_config_trustedusercakeys_real -%>
TrustedUserCAKeys <%= @sshd_config_trustedusercakeys_real %> TrustedUserCAKeys <%= @sshd_config_trustedusercakeys_real %>