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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# $Id: supervise.pp 1250 2009-12-09 01:43:27Z monachus $
class global::supervise {
# This can be overridden in a client config
$service_dir = "/service"
# === Overview
# This sets up the daemontools environment according to our needs. We
# link from /service to directories in /etc/service.d.
#
# === Variables
# None
#
# === Usage
# To set up a default daemontools environment, simply call:
#
# daemontools { $fqdn: }
#
define supervise() {
# Install daemontools and keep it current
os::package { "daemontools":
ensure => latest,
}
# Don't enable svscan because we run it out of inittab
service { "svscan":
enable => false,
running => false,
}
# Make sure our directory is in place
file { $service:
ensure => directory,
require => Package["daemontools"],
}
# Make sure our target directory is in place
file { "/etc/service.d":
ensure => directory,
mode => 0644,
require => Package["daemontools"],
}
}
# === Overview
# This will create a link from <tt>/etc/service.d/something</tt> to
# <tt>/service/something</tt>. We force the user to specify the
# full path to +target+ in case it's not in <tt>/etc/service.d</tt>.
#
# Once this link is made, the service will come up, so call this
# after you call <tt>setup_env</tt> below.
#
# === Variables
# +target+:: Target for symlink []
#
# === Usage
# To create a link to a service "tinydns" use the following:
#
# link { "tinydns":
# target => "/etc/service.d/tinydns",
# }
#
define link( $target ) {
file { "service-${name}":
path => "${service}/${name}",
ensure => $target,
require => Service["svscan"],
}
}
# === Overview
# This will create a full daemontools directory from puppet sources. It pulls
# the source directory in its entirety from the specified source location.
#
# If the title has <tt>::</tt> in it, then those are broken out into <tt>/</tt>
# to designate a location.
#
# === Variables
# +user+:: Owner of the directory [+root+]
# +group+:: Group owner of the directory [<tt>$rootgroup</tt>]
# +log+:: If we're using multilog to write to <tt>/var/log/service</tt> [+false+]
# +svcdir+:: Target service directory [<tt>/etc/service.d</tt>]
#
# === Usage
# To set up an environment for "tinydns" with defaults:
#
# setup_env { "tinydns":
# log => true,
# user => "tinydns",
# }
#
# A more complicated example that gets its content from <tt>modules/arces/ldap/server/service.d</tt>
# and writes it out as <tt>/etc/service.d/slapd</tt>
#
# setup_env { "arces::ldap::server":
# name => "slapd",
# }
define setup_env( $user="root", $group=$rootgroup, log=false, $svcdir="/etc/service.d" ) {
# turn :: into /
$location = regsubst( $title, '::', '/' )
# set up our log destination
if( $log ) {
file { "/var/log/${name}":
ensure => directory,
owner => $user,
group => $group,
mode => 0640,
}
} else {
file { "/var/log/${name}":
ensure => absent,
}
}
# Bring over our service.d content and make sure it sticks
file { "svcdir_${name}":
path => "${svcdir}/${name}",
ensure => directory,
mode => 0640,
source => [
"puppet:///${client}/${location}/service.d.${hostname}",
"puppet:///${client}/${location}/service.d.${cluster}",
"puppet:///${client}/${location}/service.d",
"puppet:///global/${location}/service.d",
],
recurse => true,
force => true,
purge => true,
ignore => ["supervise"],
}
}
}
|