This commit is contained in:
John Bintz 2012-05-09 12:57:30 -04:00
commit cf9406f84c
7 changed files with 35 additions and 112 deletions

View File

@ -1,5 +1,5 @@
class basics { class basics {
$packages = [ "ntp", "ntpdate", "gcc", "curl", "build-essential", "patch", 'sysstat', 'git-core' ] $packages = [ "ntp", "ntpdate", "gcc", "curl", "build-essential", "patch", 'sysstat', 'git-core', 'vim' ]
package { $packages: ensure => installed } package { $packages: ensure => installed }
bash_rc { "/etc/bash.bashrc": ensure => present } bash_rc { "/etc/bash.bashrc": ensure => present }
@ -11,6 +11,7 @@ class base {
$install_path = "/usr/local" $install_path = "/usr/local"
$config_path = "/etc" $config_path = "/etc"
$pid_path = "/var/run" $pid_path = "/var/run"
$data_path = "/var/data"
$log_path = "/var/log" $log_path = "/var/log"
$local_path = $install_path $local_path = $install_path
$share_path = "/usr/local/share" $share_path = "/usr/local/share"

View File

@ -1,29 +1,12 @@
class god-debian { class god-debian {
class { god: } class { god: }
$init_d_prolog = template('god-debian/init_d_prolog') init_d_bundle { 'god':
$init_d_prerun = template('god-debian/init_d_prerun') init_d_prolog => template('god-debian/init_d_prolog'),
init_d_prerun => template('god-debian/init_d_prerun'),
$god_init_d = "${base::share_path}/god/god-init.d"
file { $god_init_d:
content => template('god/god-init.d'),
require => File[$god::share],
mode => 755
}
file { 'etc/init.d/god':
ensure => $god_init_d,
require => Class['god'] require => Class['god']
} }
update_rc_d_defaults { 'god':
require => File['/etc/init.d/god']
}
running_service { 'god':
require => Update_rc_d_defaults['god']
}
file { '/usr/local/sbin/resurrect': file { '/usr/local/sbin/resurrect':
content => template('god-debian/resurrect'), content => template('god-debian/resurrect'),
mode => 755 mode => 755

View File

@ -1,6 +1,6 @@
set -e set -e
# Make sure the binary and the config file are present before proceeding # Make sure the binary and the config file are present before proceeding
test -x <%= god_bin %> || exit 0 test -x <%= scope.lookupvar('god::bin') %> || exit 0
. /lib/lsb/init-functions . /lib/lsb/init-functions

View File

@ -1,12 +1,19 @@
class varnish($version, $store_file_mb = 1024) { class varnish($version, $store_file_mb = 1024) {
$install_path = install_path($name, $version) $install_path = install_path($name, $version)
$pid = pid_path($name)
$log = log_path($name)
$config = config_path($name) $config = config_path($name)
$share = share_path($name) $share = share_path($name)
$data = data_path($name) $data = data_path($name)
$sbin = sbin_path($name)
$bin_path = bin_path($name)
$bin = "${sbin}/${name}d"
$pid = pid_path($name)
$log = log_path($name)
$ncsa_bin = "${bin_path}/varnishncsa"
$ncsa_pid = pid_path('varnishncsa')
$ncsa_log = $log
$bin = "${name}d"
$sysconfig_dir = "${config}/sysconfig" $sysconfig_dir = "${config}/sysconfig"
$vcl_path = "${config}/default.vcl" $vcl_path = "${config}/default.vcl"
@ -28,7 +35,7 @@ class varnish($version, $store_file_mb = 1024) {
source => "http://repo.varnish-cache.org/source/varnish-<%= scope.lookupvar('version') %>.tar.gz" source => "http://repo.varnish-cache.org/source/varnish-<%= scope.lookupvar('version') %>.tar.gz"
} }
mkdir_p { [ $config, $share, $sysconfig_dir, $data ]: mkdir_p { [ $config, $log, $share, $sysconfig_dir, $data ]:
path => $base::path, path => $base::path,
require => Build_and_install[$name] require => Build_and_install[$name]
} }
@ -48,4 +55,16 @@ class varnish($version, $store_file_mb = 1024) {
require => Mkdir_p[$data], require => Mkdir_p[$data],
logoutput => true logoutput => true
} }
$varnish_start = "service varnish start"
$varnish_stop = "service varnish stop"
god_init { $name:
start => $varnish_start,
stop => $varnish_stop,
restart => "${varnish_stop} && ${varnish_start}",
pid_file => $pid,
ensure => present,
require => Build_and_install[$name]
}
} }

View File

@ -1,9 +1,7 @@
VARNISH_LISTEN_ADDRESS=0.0.0.0
VARNISH_LISTEN_PORT=80
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
DAEMON_OPTS="\ DAEMON_OPTS="\
-T 127.0.0.1:6082 \ -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:6082 \
-u ${VARNISH_USERNAME} -g ${VARNISH_PASSWORD} \ -u ${VARNISH_USERNAME} -g ${VARNISH_GROUP} \
-w 1,1,3600 \ -w 1,1,3600 \
-f ${VARNISH_VCL_CONF} \ -f ${VARNISH_VCL_CONF} \
-s ${VARNISH_BACKEND_STORE} \ -s ${VARNISH_BACKEND_STORE} \

View File

@ -1,82 +0,0 @@
#!/bin/sh
<%= init_d_prolog %>
NAME=varnish
DESC=varnish
BIN=<%= scope.lookupvar('varnish::bin') %>
PID=<%= scope.lookupvar('varnish::pid') %>
LOG=<%= scope.lookupvar('varnish::log') %>
OVERRIDE_CONFIG=<%= scope.lookupvar('varnish::override_config') %>
<%= init_d_prerun %>
RETVAL=0
VARNISH_VCL_CONF=<%= scope.lookupvar('varnish::vcl_path') %>
VARNISH_BACKEND_STORE="file,<%= scope.lookupvar('varnish::store_file_path') %>,<%= scope.lookupvar('varnish::store_file_size') %>"
VARNISH_USERNAME=<%= username %>
VARNISH_PASSWORD=<%= password %>
# Include varnish defaults
[ -e $OVERRIDE_CONFIG ] && . $OVERRIDE_CONFIG
start() {
echo -n "Starting $DESC: "
rm -Rf $PID
ulimit -n ${NFILES:-131072}
ulimit -l ${MEMLOCK:-82000}
# Varnish always gives output on STDOUT
$BIN -P $pidfile "$DAEMON_OPTS" > /dev/null 2>&1
echo "$NAME."
RETVAL=$?
return $RETVAL
}
stop() {
echo -n "Stopping $DESC: "
if [ -f $PID ]; then
kill `cat $PID`
rm $PID
fi
killall -9 $VARNISH || true
echo "$NAME."
return 0
}
status_q() {
test -f $PID
}
configtest() {
$BIN -f "$VARNISH_VCL_CONF" -C -n /tmp > /dev/null && echo "Syntax ok"
}
# See how we were called.
case "$1" in
start)
status_q && exit 0
$1
;;
stop)
status_q || exit 0
$1
;;
restart)
status_q
if [ $? -eq 0 ]; then stop; fi
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 2
esac
exit $?

View File

@ -28,6 +28,10 @@ module Puppet
def share_path(share_path, name) def share_path(share_path, name)
File.join(share_path, name) File.join(share_path, name)
end end
def data_path(data_path, name)
File.join(data_path, name)
end
end end
end end
end end