From 376b8738fa603d8de166910e9c0fe751999e7940 Mon Sep 17 00:00:00 2001 From: Phil Friderici Date: Wed, 16 Oct 2013 12:44:31 +0200 Subject: [PATCH 1/4] Fixed undef variables problems in ssh_config.erb --- templates/ssh_config.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/ssh_config.erb b/templates/ssh_config.erb index e5ab70f..743a15b 100644 --- a/templates/ssh_config.erb +++ b/templates/ssh_config.erb @@ -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 From 78ed132af312c6b30745a9646ac58d8783f3b8fb Mon Sep 17 00:00:00 2001 From: Phil Friderici Date: Wed, 16 Oct 2013 12:47:06 +0200 Subject: [PATCH 2/4] Removed duplicate documentation from module --- manifests/init.pp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index f502a6d..aa106e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,19 +1,6 @@ -# == Class: ssh +# ## 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', From 7bc00797ae9a797ce7f712b81436da301d2fc2f0 Mon Sep 17 00:00:00 2001 From: Phil Friderici Date: Thu, 17 Oct 2013 15:46:28 +0200 Subject: [PATCH 3/4] Fixed header --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index aa106e4..a630b8f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,4 @@ -# ## Class: ssh ## +# == Class: ssh # # Manage ssh client and server # From 55da6eeb92a3207b7821b13778a50fd1d2827173 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 17 Oct 2013 16:44:41 -0400 Subject: [PATCH 4/4] Add spec tests for ssh_config template --- spec/classes/init_spec.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 66ab8c8..9e8ecd0 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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 {