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-01-02 21:02:15 +01:00
|
|
|
case $operatingsystem {
|
|
|
|
OpenBSD: {
|
2008-01-04 15:16:20 +01:00
|
|
|
exec{sshd_refresh:
|
2008-01-31 00:27:37 +01:00
|
|
|
command => "/bin/kill -HUP `/bin/cat /var/run/sshd.pid`",
|
|
|
|
refreshonly => true,
|
|
|
|
}
|
2008-01-02 21:05:30 +01:00
|
|
|
}
|
2008-01-02 21:02:15 +01:00
|
|
|
default: {
|
|
|
|
service{'sshd':
|
2008-02-02 01:42:12 +01:00
|
|
|
name => $operatingsystem ? {
|
|
|
|
debian => 'ssh',
|
|
|
|
ubuntu => 'ssh',
|
|
|
|
default => 'sshd',
|
|
|
|
},
|
2008-01-30 23:51:09 +01:00
|
|
|
enable => true,
|
|
|
|
ensure => running,
|
2008-01-02 21:02:15 +01:00
|
|
|
require => Package[openssh],
|
2008-01-30 23:51:09 +01:00
|
|
|
}
|
2008-02-02 01:23:09 +01:00
|
|
|
|
2008-01-02 21:02:15 +01:00
|
|
|
package{openssh:
|
2008-02-02 01:36:44 +01:00
|
|
|
name => $operatingsystem ? {
|
2008-02-02 01:44:07 +01:00
|
|
|
debian => 'openssh-server',
|
|
|
|
ubuntu => 'openssh-server',
|
|
|
|
redhat => 'openssh-server',
|
|
|
|
centos => 'openssh-server',
|
|
|
|
default => 'openssh',
|
2008-02-02 01:36:44 +01:00
|
|
|
},
|
2008-01-31 00:27:37 +01:00
|
|
|
category => $operatingsystem ? {
|
|
|
|
gentoo => 'net-misc',
|
|
|
|
default => '',
|
|
|
|
},
|
|
|
|
ensure => present,
|
2008-01-02 21:02:15 +01:00
|
|
|
}
|
2008-02-02 01:23:09 +01:00
|
|
|
|
2008-01-02 21:02:15 +01:00
|
|
|
}
|
2008-01-02 20:40:42 +01:00
|
|
|
}
|
2007-12-21 18:52:01 +01:00
|
|
|
}
|
|
|
|
|
2008-02-17 21:50:47 +01:00
|
|
|
define sshd::sshd_config(
|
2008-02-17 21:48:17 +01:00
|
|
|
$source => ''
|
2007-12-21 18:52:01 +01:00
|
|
|
){
|
|
|
|
$real_source = $source ? {
|
2007-12-27 16:42:16 +01:00
|
|
|
'' => "${operatingsystem}_normal.erb",
|
2007-12-21 18:52:01 +01:00
|
|
|
default => $source,
|
|
|
|
}
|
|
|
|
|
2008-02-17 21:50:47 +01:00
|
|
|
$real_allowed_users = $sshd_allowed_users ? {
|
2008-02-17 20:46:11 +01:00
|
|
|
'' => 'root',
|
|
|
|
default => $sshd_allowed_users,
|
|
|
|
}
|
|
|
|
|
2007-12-21 18:52:01 +01:00
|
|
|
file { 'sshd_config':
|
2008-01-31 00:27:37 +01:00
|
|
|
path => '/etc/ssh/sshd_config',
|
|
|
|
owner => root,
|
|
|
|
group => 0,
|
|
|
|
mode => 600,
|
|
|
|
content => template("sshd/sshd_config/${real_source}"),
|
2008-01-04 15:16:20 +01:00
|
|
|
notify => $operatingsystem ? {
|
|
|
|
openbsd => Exec[sshd_refresh],
|
|
|
|
default => Service[sshd],
|
2008-01-31 00:27:37 +01:00
|
|
|
},
|
|
|
|
}
|
2007-12-21 18:52:01 +01:00
|
|
|
}
|
2008-02-17 20:46:11 +01:00
|
|
|
|
|
|
|
define sshd::deploy_auth_key(
|
|
|
|
$source => '',
|
|
|
|
$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 ? {
|
|
|
|
'' => "sshd/authorized_keys/${name}",
|
|
|
|
default => $source,
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
source => "puppet://$server/$source",
|
|
|
|
}
|
|
|
|
}
|