Merge pull request #18 from ghoneycutt/fix_undef_variables_in_template

Fix undef variables in template
This commit is contained in:
Garrett Honeycutt 2013-10-17 13:51:45 -07:00
commit 3ddacee430
3 changed files with 41 additions and 17 deletions

View File

@ -1,19 +1,6 @@
# == Class: ssh
#
# Manage ssh client and server.
#
# Sample usage:
# # Push authorized key "root_for_userX" and remove key "root_for_userY" with hiera
#
# ssh::keys:
# root_for_userX:
# ensure: present
# user: root
# type: dsa
# key: AAAA...==
# root_for_userY:
# ensure: absent
# user: root
# Manage ssh client and server
#
class ssh (
$packages = 'USE_DEFAULTS',

View File

@ -35,6 +35,10 @@ describe 'ssh' do
should contain_file('ssh_config').with_content(/^# This file is being maintained by Puppet.\n# DO NOT EDIT\n\n# \$OpenBSD: ssh_config,v 1.21 2005\/12\/06 22:38:27 reyk Exp \$/)
}
it { should_not contain_file('ssh_config').with_content(/^\s*ForwardAgent$/) }
it { should_not contain_file('ssh_config').with_content(/^\s*ForwardX11$/) }
it { should_not contain_file('ssh_config').with_content(/^\s*ServerAliveInterval$/) }
it {
should contain_file('sshd_config').with({
'ensure' => 'file',
@ -100,6 +104,39 @@ describe 'ssh' do
}
end
context 'with optional params used in ssh_config set on osfamily RedHat' do
let :facts do
{
:fqdn => 'monkey.example.com',
:osfamily => 'RedHat',
:sshrsakey => 'AAAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ=='
}
end
let :params do
{
:ssh_config_forward_agent => 'yes',
:ssh_config_forward_x11 => 'yes',
:ssh_config_server_alive_interval => '300',
}
end
it {
should contain_file('ssh_config').with({
'ensure' => 'file',
'path' => '/etc/ssh/ssh_config',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'require' => 'Package[ssh_packages]',
})
}
it { should contain_file('ssh_config').with_content(/^# This file is being maintained by Puppet.\n# DO NOT EDIT\n\n# \$OpenBSD: ssh_config,v 1.21 2005\/12\/06 22:38:27 reyk Exp \$/) }
it { should contain_file('ssh_config').with_content(/^ ForwardAgent yes$/) }
it { should contain_file('ssh_config').with_content(/^ ForwardX11 yes$/) }
it { should contain_file('ssh_config').with_content(/^ ServerAliveInterval 300$/) }
end
context 'with manage_root_ssh_config set to \'true\' on valid osfamily' do
let :facts do
{

View File

@ -50,13 +50,13 @@ Host *
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
ForwardX11Trusted yes
<% if @ssh_config_forward_agent -%>
<% if @ssh_config_forward_agent != nil -%>
ForwardAgent <%= @ssh_config_forward_agent %>
<% end -%>
<% if @ssh_config_forward_x11 -%>
<% if @ssh_config_forward_x11 != nil -%>
ForwardX11 <%= @ssh_config_forward_x11 %>
<% end -%>
<% if @ssh_config_server_alive_interval -%>
<% if @ssh_config_server_alive_interval != nil -%>
ServerAliveInterval <%= @ssh_config_server_alive_interval %>
<% end -%>
# Send locale-related environment variables