aboutsummaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: f800ca62c7f76aae3131e439723406c76f737aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# modules/ssh/manifests/init.pp - manage ssh stuff
# Copyright (C) 2007 admin@immerda.ch
#

modules_dir { "sshd": }

class sshd {

	case $operatingsystem {
		OpenBSD: {
			exec{sshd_refresh:
        			command => "/bin/kill -HUP `/bin/cat /var/run/sshd.pid`",
	                	refreshonly => true,
        		}
		}
		default: {
			service{'sshd':
                                enable => true,
                                ensure => running,
				require => Package[openssh],
                        }
			
			package{openssh:
		        	name =>  $operatingsystem ? {
        		        	centos => openssh-server,
                			default => openssh,
			        },
        			alias   => 'openssh',
                		category => $operatingsystem ? {
	                	        gentoo => 'net-misc',
		        		default => '',
	        		},
		        	ensure => present,
			}
		}
	}

	
}

define sshd::sshd_config (
	$source = "",
	$allowed_users = 'root'
){
	$real_source = $source ? {
		'' => "${operatingsystem}_normal.erb",
		default => $source,
	}

	file { 'sshd_config':
                path => '/etc/ssh/sshd_config',
                owner => root,
                group => 0,
                mode => 600,
                content => template("sshd/sshd_config/${real_source}"),
		notify => $operatingsystem ? { 
			openbsd => Exec[sshd_refresh],
			default => Service[sshd],
		}
        }
}