2007-12-21 18:52:01 +01:00
|
|
|
# modules/ssh/manifests/init.pp - manage ssh stuff
|
|
|
|
# Copyright (C) 2007 admin@immerda.ch
|
|
|
|
#
|
|
|
|
|
2008-01-11 16:58:16 +01:00
|
|
|
#modules_dir { "sshd": }
|
2007-12-21 18:52:01 +01:00
|
|
|
|
|
|
|
class sshd {
|
2008-04-04 17:30:26 +02:00
|
|
|
case $operatingsystem {
|
|
|
|
gentoo: { include sshd::gentoo }
|
|
|
|
redhat: { include sshd::redhat }
|
|
|
|
centos: { include sshd::centos }
|
|
|
|
openbsd: { include sshd::openbsd }
|
|
|
|
default: { include sshd::default }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-21 18:52:01 +01:00
|
|
|
|
2008-04-04 17:30:26 +02:00
|
|
|
class sshd::base {
|
2008-02-29 13:09:18 +01:00
|
|
|
$real_sshd_config_source = $sshd_config_source ? {
|
|
|
|
'' => "sshd/sshd_config/${operatingsystem}_normal.erb",
|
|
|
|
default => $source,
|
2007-12-21 18:52:01 +01:00
|
|
|
}
|
|
|
|
|
2008-02-29 11:41:44 +01:00
|
|
|
$real_sshd_allowed_users = $sshd_allowed_users ? {
|
|
|
|
'' => 'root',
|
2008-02-29 13:09:18 +01:00
|
|
|
default => $sshd_allowed_users,
|
2008-02-29 11:41:44 +01:00
|
|
|
}
|
2008-02-17 20:46:11 +01:00
|
|
|
|
2008-02-29 13:09:18 +01:00
|
|
|
file { 'sshd_config':
|
2008-01-31 00:27:37 +01:00
|
|
|
path => '/etc/ssh/sshd_config',
|
|
|
|
owner => root,
|
|
|
|
group => 0,
|
|
|
|
mode => 600,
|
2008-02-29 13:09:18 +01:00
|
|
|
content => template("${real_sshd_config_source}"),
|
2008-01-31 00:27:37 +01:00
|
|
|
}
|
2007-12-21 18:52:01 +01:00
|
|
|
}
|
2008-02-17 20:46:11 +01:00
|
|
|
|
2008-04-04 17:30:26 +02:00
|
|
|
class sshd::linux inherits sshd::base {
|
|
|
|
package{openssh:
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
include sshd::service
|
|
|
|
File[sshd_config]{
|
|
|
|
notify => Service[sshd],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class sshd::gentoo inherits sshd::linux {
|
|
|
|
Package[openssh]{
|
|
|
|
category => 'net-misc',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class sshd::debian inherits sshd::linux {
|
|
|
|
Package[openssh]{
|
|
|
|
name => 'openssh-server',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class sshd::ubuntu inherits sshd::debian {}
|
|
|
|
|
|
|
|
class sshd::redhat inherits sshd::linux {
|
|
|
|
Package[openssh]{
|
|
|
|
name => 'openssh-server',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class sshd::centos inherits sshd::redhat {}
|
|
|
|
|
|
|
|
class sshd::openbsd inherits sshd::base {
|
|
|
|
exec{sshd_refresh:
|
|
|
|
command => "/bin/kill -HUP `/bin/cat /var/run/sshd.pid`",
|
|
|
|
refreshonly => true,
|
|
|
|
}
|
|
|
|
File[sshd_config]{
|
|
|
|
notify => Exec[sshd_refresh],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
### service stuff
|
|
|
|
class sshd::service {
|
|
|
|
case $operatingsystem {
|
|
|
|
debian: { include sshd::service::debian }
|
|
|
|
ubuntu: { include sshd::service::ubuntu }
|
|
|
|
default: { include sshd::service::base }
|
|
|
|
}
|
|
|
|
|
|
|
|
class sshd::service::base {
|
|
|
|
service{'sshd':
|
|
|
|
name => 'sshd',
|
|
|
|
enable => true,
|
|
|
|
ensure => running,
|
|
|
|
require => Package[openssh],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class sshd::service::debian inherits sshd::service::base {
|
|
|
|
Service[sshd]{
|
|
|
|
name => 'ssh',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class sshd::service::ubuntu inherits sshd::service::debian {}
|
|
|
|
|
|
|
|
### defines
|
2008-02-17 20:46:11 +01:00
|
|
|
define sshd::deploy_auth_key(
|
2008-02-17 21:55:26 +01:00
|
|
|
$source = '',
|
2008-02-17 20:46:11 +01:00
|
|
|
$user = 'root',
|
|
|
|
$target_dir = '/root/.ssh/',
|
|
|
|
$group = '' ) {
|
|
|
|
|
|
|
|
$real_target = $target_dir ? {
|
|
|
|
'' => "/home/$user/.ssh/",
|
|
|
|
default => $target_dir,
|
|
|
|
}
|
|
|
|
|
|
|
|
$real_group = $group ? {
|
|
|
|
'' => 0,
|
|
|
|
default => $group,
|
|
|
|
}
|
|
|
|
|
|
|
|
$real_source = $source ? {
|
2008-04-04 17:30:26 +02:00
|
|
|
'' => [ "puppet://$server/files/sshd/authorized_keys/${name}",
|
|
|
|
"puppet://$server/sshd/authorized_keys/${name}" ]
|
2008-02-29 14:51:45 +01:00
|
|
|
default => "puppet://$server/$source",
|
2008-02-17 20:46:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
file {$real_target:
|
|
|
|
ensure => directory,
|
|
|
|
owner => $user,
|
|
|
|
group => $real_group,
|
|
|
|
mode => 700,
|
|
|
|
}
|
|
|
|
|
|
|
|
file {"authorized_keys_${user}":
|
|
|
|
path => "$real_target/authorized_keys",
|
|
|
|
owner => $user,
|
|
|
|
group => $real_group,
|
|
|
|
mode => 600,
|
2008-02-29 14:51:45 +01:00
|
|
|
source => $real_source,
|
2008-02-17 20:46:11 +01:00
|
|
|
}
|
|
|
|
}
|