From 44ce57a8bc46cf8089be5519d15d970f27f05a94 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 8 May 2012 15:10:26 -0400 Subject: [PATCH] more updates --- .../debian-base/manifests/init.pp | 3 +- .../god-debian/manifests/init.pp | 23 +----- .../god-debian/templates/init_d_prerun | 2 +- .../god/templates/god-init.d-base | 80 ------------------ .../varnish/manifests/init.pp | 32 ++++++-- .../varnish/templates/defaults | 6 +- .../varnish/templates/varnish-init.d-base | 82 ------------------- .../lib/puppet/modules/common_directories.rb | 4 + 8 files changed, 35 insertions(+), 197 deletions(-) delete mode 100644 shared/additional-modules/god/templates/god-init.d-base delete mode 100644 shared/additional-modules/varnish/templates/varnish-init.d-base diff --git a/shared/additional-modules/debian-base/manifests/init.pp b/shared/additional-modules/debian-base/manifests/init.pp index 5903312..e764e44 100644 --- a/shared/additional-modules/debian-base/manifests/init.pp +++ b/shared/additional-modules/debian-base/manifests/init.pp @@ -1,5 +1,5 @@ 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 } bash_rc { "/etc/bash.bashrc": ensure => present } @@ -11,6 +11,7 @@ class base { $install_path = "/usr/local" $config_path = "/etc" $pid_path = "/var/run" + $data_path = "/var/data" $log_path = "/var/log" $local_path = $install_path $share_path = "/usr/local/share" diff --git a/shared/additional-modules/god-debian/manifests/init.pp b/shared/additional-modules/god-debian/manifests/init.pp index e07471e..9205ec2 100644 --- a/shared/additional-modules/god-debian/manifests/init.pp +++ b/shared/additional-modules/god-debian/manifests/init.pp @@ -1,29 +1,12 @@ 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'), - require => File[$god::share], - mode => 755 - } - - file { 'etc/init.d/god': - ensure => $god_init_d, + init_d_bundle { 'god': + init_d_prolog => template('god-debian/init_d_prolog'), + init_d_prerun => template('god-debian/init_d_prerun'), 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': content => template('god-debian/resurrect'), mode => 755 diff --git a/shared/additional-modules/god-debian/templates/init_d_prerun b/shared/additional-modules/god-debian/templates/init_d_prerun index 657df07..4d29562 100644 --- a/shared/additional-modules/god-debian/templates/init_d_prerun +++ b/shared/additional-modules/god-debian/templates/init_d_prerun @@ -1,6 +1,6 @@ set -e # 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 diff --git a/shared/additional-modules/god/templates/god-init.d-base b/shared/additional-modules/god/templates/god-init.d-base deleted file mode 100644 index 78d9efe..0000000 --- a/shared/additional-modules/god/templates/god-init.d-base +++ /dev/null @@ -1,80 +0,0 @@ -#!/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 - diff --git a/shared/additional-modules/varnish/manifests/init.pp b/shared/additional-modules/varnish/manifests/init.pp index 541764c..69e062c 100644 --- a/shared/additional-modules/varnish/manifests/init.pp +++ b/shared/additional-modules/varnish/manifests/init.pp @@ -1,12 +1,19 @@ 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) + $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" $vcl_path = "${config}/default.vcl" @@ -28,16 +35,11 @@ class varnish($version, $store_file_mb = 1024) { 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, 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, @@ -53,4 +55,16 @@ class varnish($version, $store_file_mb = 1024) { require => Mkdir_p[$data], 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] + } } diff --git a/shared/additional-modules/varnish/templates/defaults b/shared/additional-modules/varnish/templates/defaults index 6c94c1f..02afcd0 100644 --- a/shared/additional-modules/varnish/templates/defaults +++ b/shared/additional-modules/varnish/templates/defaults @@ -1,9 +1,7 @@ -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} \ + -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:6082 \ + -u ${VARNISH_USERNAME} -g ${VARNISH_GROUP} \ -w 1,1,3600 \ -f ${VARNISH_VCL_CONF} \ -s ${VARNISH_BACKEND_STORE} \ diff --git a/shared/additional-modules/varnish/templates/varnish-init.d-base b/shared/additional-modules/varnish/templates/varnish-init.d-base deleted file mode 100644 index baeb1fe..0000000 --- a/shared/additional-modules/varnish/templates/varnish-init.d-base +++ /dev/null @@ -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 $? - diff --git a/shared/lib/puppet/modules/common_directories.rb b/shared/lib/puppet/modules/common_directories.rb index 094a9db..1d39cde 100644 --- a/shared/lib/puppet/modules/common_directories.rb +++ b/shared/lib/puppet/modules/common_directories.rb @@ -28,6 +28,10 @@ module Puppet def share_path(share_path, name) File.join(share_path, name) end + + def data_path(data_path, name) + File.join(data_path, name) + end end end end