wow a ton of changes
This commit is contained in:
parent
61f6767c8e
commit
0612d07a40
@ -11,6 +11,7 @@ class base {
|
||||
$install_path = "/usr/local"
|
||||
$config_path = "/etc"
|
||||
$pid_path = "/var/run"
|
||||
$log_path = "/var/log"
|
||||
$local_path = $install_path
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
class god-debian {
|
||||
class { god: }
|
||||
|
||||
$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'),
|
||||
|
@ -1,82 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: god
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: God
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/ruby/bin:<%= scope.lookupvar('base::path') %>
|
||||
NAME=god
|
||||
DESC=god
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure the binary and the config file are present before proceeding
|
||||
test -x <%= god_bin %> || exit 0
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
PID_PATH=<%= pid_path %>
|
||||
|
||||
start() {
|
||||
echo -n "Starting $DESC: "
|
||||
rm -f $PID_PATH
|
||||
<%= god_bin %> -P $PID_PATH -l /var/log/god.log
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
sleep 2
|
||||
if [ -d <%= god_dir %> ]; then
|
||||
for file in $(find <%= god_dir %> -name "*.god"); do
|
||||
echo "god: loading $file ..."
|
||||
<%= god_bin %> load $file
|
||||
done
|
||||
fi
|
||||
fi
|
||||
echo "$NAME."
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Stopping $DESC: "
|
||||
if [ -f $PID_PATH ]; then
|
||||
kill `cat $PID_PATH`
|
||||
rm $PID_PATH
|
||||
fi
|
||||
|
||||
killall -9 <%= god_bin %> || true
|
||||
echo "$NAME."
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
<%= god_bin %> status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: god {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
@ -0,0 +1,6 @@
|
||||
set -e
|
||||
|
||||
# Make sure the binary and the config file are present before proceeding
|
||||
test -x <%= god_bin %> || exit 0
|
||||
|
||||
. /lib/lsb/init-functions
|
@ -0,0 +1,9 @@
|
||||
### BEGIN INIT INFO
|
||||
# Provides: god
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: God
|
||||
### END INIT INFO
|
||||
|
@ -5,15 +5,14 @@ class god {
|
||||
require => Make_and_install['ruby']
|
||||
}
|
||||
|
||||
$god_bin = "${base::install_path}/ruby/bin/god"
|
||||
$god_dir = "${base::config_path}/god.d"
|
||||
$pid_path = pid_path($name)
|
||||
$bin = "${base::install_path}/ruby/bin/god"
|
||||
$dir = config_path("god.d")
|
||||
$pid = pid_path($name)
|
||||
$log = log_path($name)
|
||||
$share = share_path($name)
|
||||
|
||||
file { $god_dir:
|
||||
file { [ $dir, $share ]:
|
||||
ensure => directory
|
||||
}
|
||||
|
||||
$share = "${base::share_path}/god"
|
||||
file { $share: ensure => directory }
|
||||
}
|
||||
|
||||
|
80
shared/additional-modules/god/templates/god-init.d-base
Normal file
80
shared/additional-modules/god/templates/god-init.d-base
Normal file
@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
<%= init_d_prolog %>
|
||||
|
||||
PATH=/usr/local/ruby/bin:<%= scope.lookupvar('base::path') %>
|
||||
NAME=god
|
||||
DESC=god
|
||||
|
||||
BIN=<%= scope.lookupvar('god::bin') %>
|
||||
PID=<%= scope.lookupvar('god::pid') %>
|
||||
DIR=<%= scope.lookupvar('god::dir') %>
|
||||
LOG=<%= scope.lookupvar('god::log') %>
|
||||
|
||||
<%= init_d_prerun %>
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n "Starting $DESC: "
|
||||
rm -f $PID
|
||||
$BIN -P $PID -l $LOG
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
sleep 2
|
||||
if [ -d $DIR ]; then
|
||||
for file in $(find $DIR -name "*.god"); do
|
||||
echo "$NAME: loading $file ..."
|
||||
$BIN load $file
|
||||
done
|
||||
fi
|
||||
fi
|
||||
echo "$NAME."
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Stopping $DESC: "
|
||||
if [ -f $PID ]; then
|
||||
kill `cat $PID`
|
||||
rm $PID
|
||||
fi
|
||||
|
||||
killall -9 $BIN || true
|
||||
echo "$NAME."
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
status_q() {
|
||||
test -f $PID
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
status_q && exit 0
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
status_q || exit 0
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
status_q
|
||||
if [ $? -eq 0 ]; then stop; fi
|
||||
start
|
||||
;;
|
||||
status)
|
||||
$BIN status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $NAME {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
15
shared/additional-modules/varnish-vcl/manifests/init.pp
Normal file
15
shared/additional-modules/varnish-vcl/manifests/init.pp
Normal file
@ -0,0 +1,15 @@
|
||||
class varnish-default-vcl {
|
||||
$backend_port = '8080'
|
||||
$assets_age = 86400
|
||||
$no_ttl_time = "10m"
|
||||
|
||||
$healthy_grace_time = "1m"
|
||||
$sick_grace_time = "24h"
|
||||
$probe_interval = "3s"
|
||||
|
||||
file { $varnish::vcl_path:
|
||||
content => template('varnish-default-vcl/default.vcl'),
|
||||
require => [ Build_and_install[$name], Mkdir_p[$config_path] ],
|
||||
}
|
||||
}
|
||||
|
56
shared/additional-modules/varnish/manifests/init.pp
Normal file
56
shared/additional-modules/varnish/manifests/init.pp
Normal file
@ -0,0 +1,56 @@
|
||||
class varnish($version, $store_file_mb = 1024) {
|
||||
$install_path = install_path($name, $version)
|
||||
$pid = pid_path($name)
|
||||
$log = log_path($name)
|
||||
$config = config_path($name)
|
||||
$share = share_path($name)
|
||||
$data = data_path($name)
|
||||
|
||||
$bin = "${name}d"
|
||||
$sysconfig_dir = "${config}/sysconfig"
|
||||
$vcl_path = "${config}/default.vcl"
|
||||
|
||||
$override_config = "${sysconfig_dir}/${name}"
|
||||
|
||||
$store_file_path = "${data}/store"
|
||||
$store_file_size = $store_file_mb * 1024 * 1024
|
||||
|
||||
$backend_port = '8080'
|
||||
$assets_age = 86400
|
||||
$no_ttl_time = "10m"
|
||||
|
||||
$healthy_grace_time = "1m"
|
||||
$sick_grace_time = "24h"
|
||||
$probe_interval = "3s"
|
||||
|
||||
build_and_install { $name:
|
||||
version => $version,
|
||||
source => "http://repo.varnish-cache.org/source/varnish-<%= scope.lookupvar('version') %>.tar.gz"
|
||||
}
|
||||
|
||||
mkdir_p { [ $config, $share, $sysconfig_dir, $data ]:
|
||||
path => $base::path,
|
||||
require => Build_and_install[$name]
|
||||
}
|
||||
|
||||
file { $varnish::vcl_path:
|
||||
content => template('varnish-redhat/default.vcl'),
|
||||
require => [ Mkdir_p[$config] ]
|
||||
}
|
||||
|
||||
file { $override_config:
|
||||
ensure => present,
|
||||
mode => 644,
|
||||
content => template('varnish/defaults'),
|
||||
require => Mkdir_p[$sysconfig_dir],
|
||||
}
|
||||
|
||||
exec { 'create-store-file':
|
||||
command => "dd if=/dev/zero of=${store_file_path} bs=${store_file_size} count=1",
|
||||
timeout => 0,
|
||||
unless => "test -f ${store_file_path}",
|
||||
path => $base::path,
|
||||
require => Mkdir_p[$data],
|
||||
logoutput => true
|
||||
}
|
||||
}
|
11
shared/additional-modules/varnish/templates/defaults
Normal file
11
shared/additional-modules/varnish/templates/defaults
Normal file
@ -0,0 +1,11 @@
|
||||
VARNISH_LISTEN_ADDRESS=0.0.0.0
|
||||
VARNISH_LISTEN_PORT=80
|
||||
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
|
||||
DAEMON_OPTS="\
|
||||
-T 127.0.0.1:6082 \
|
||||
-u ${VARNISH_USERNAME} -g ${VARNISH_PASSWORD} \
|
||||
-w 1,1,3600 \
|
||||
-f ${VARNISH_VCL_CONF} \
|
||||
-s ${VARNISH_BACKEND_STORE} \
|
||||
"
|
||||
|
@ -0,0 +1,82 @@
|
||||
#!/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 $?
|
||||
|
5
shared/lib/puppet/parser/functions/config_path.rb
Normal file
5
shared/lib/puppet/parser/functions/config_path.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:config_path, :type => :rvalue) do |args|
|
||||
File.join(lookupvar('base::config_path'), *args)
|
||||
end
|
||||
end
|
6
shared/lib/puppet/parser/functions/data_path.rb
Normal file
6
shared/lib/puppet/parser/functions/data_path.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:data_path, :type => :rvalue) do |args|
|
||||
File.join(lookupvar('base::data_path'), *args)
|
||||
end
|
||||
end
|
||||
|
6
shared/lib/puppet/parser/functions/log_path.rb
Normal file
6
shared/lib/puppet/parser/functions/log_path.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:log_path, :type => :rvalue) do |args|
|
||||
File.join(lookupvar('base::log_path'), *args)
|
||||
end
|
||||
end
|
||||
|
@ -1,9 +1,7 @@
|
||||
require 'puppet/modules/common_directories'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:sbin_path, :type => :rvalue) do |args|
|
||||
sbin_path(lookupvar('base::install_path'), *args)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
6
shared/lib/puppet/parser/functions/share_path.rb
Normal file
6
shared/lib/puppet/parser/functions/share_path.rb
Normal file
@ -0,0 +1,6 @@
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:share_path, :type => :rvalue) do |args|
|
||||
File.join(lookupvar('base::share_path'), *args)
|
||||
end
|
||||
end
|
||||
|
@ -3,6 +3,7 @@ Puppet::Type.type(:download_and_unpack).provide(:action) do
|
||||
|
||||
def create
|
||||
system %{bash -c 'cd #{@resource[:src_path]} ; (curl #{@resource[:url]} | tar #{tar_command} -)'}
|
||||
raise StandardError.new("Could not download") if $?.exitstatus != 0
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -1,3 +0,0 @@
|
||||
define init_d($template) {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user