Skip to content

Commit

Permalink
use template for sshd_config file
Browse files Browse the repository at this point in the history
  • Loading branch information
saz committed Feb 24, 2014
1 parent 10426ab commit 3f82045
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
7 changes: 5 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class ssh (
$disable_user_known_hosts = true
) {
$sshd_default_options = $ssh::params::sshd_default_options,
$sshd_options = {},
$ssh_default_options = $ssh::params::ssh_default_options,
$ssh_options = {}
) inherits ssh::params {
include ssh::server
include ssh::client
}
12 changes: 12 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,16 @@
}
}
}

$sshd_default_options = {
'ChallengeResponseAuthentication' => 'no',
'X11Forwarding' => 'yes',
'PrintMotd' => 'no',
'AcceptEnv' => 'LANG LC_*',
'Subsystem' => 'sftp /usr/lib/openssh/sftp-server',
'UsePAM' => 'yes',
}

$ssh_default_options = {
}
}
18 changes: 16 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
class ssh::server {
include ssh::params
class ssh::server(
$default_options = $ssh::params::sshd_default_options,
$options = {}
) inherits ssh::params {

include ssh::server::install
include ssh::server::config
include ssh::server::service
include ssh::hostkeys
include ssh::knownhosts

anchor { 'ssh::server::start': }
anchor { 'ssh::server::end': }

Anchor['ssh::server::start'] ->
Class['ssh::server::install'] ->
Class['ssh::server::config'] ~>
Class['ssh::server::service'] ->
Class['ssh::hostkeys'] ->
Class['ssh::knownhosts'] ->
Anchor['ssh::server::end']
}
7 changes: 3 additions & 4 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
class ssh::server::config {
file { $ssh::params::sshd_config:
ensure => present,
owner => 'root',
group => 'root',
owner => 0,
group => 0,
mode => '0600',
replace => false,
source => "puppet:///modules/${module_name}/sshd_config",
content => template("${module_name}/sshd_config.erb"),
require => Class['ssh::server::install'],
notify => Class['ssh::server::service'],
}
Expand Down
9 changes: 9 additions & 0 deletions templates/sshd_config.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# File is managed by Puppet

<%- scope.lookupvar('ssh::server::default_options').each do |k, v| -%>
<%= k %> <%= v %>
<%- end -%>
<%- scope.lookupvar('ssh::server::options').each do |k, v| -%>
<%= k %> <%= v %>
<%- end -%>

0 comments on commit 3f82045

Please sign in to comment.