Merge branch 'squid'
This commit is contained in:
commit
775dedf53b
lib/puppet-standalone-mashup/capistrano
shared
additional-modules
god-debian/manifests
ruby-debian/manifests
squid
varnish-debian
modules/init_d_bundle/manifests
@ -19,7 +19,20 @@ Capistrano::Configuration.instance.load do
|
||||
end
|
||||
end
|
||||
|
||||
before 'apply', 'ensure_puppet'
|
||||
before 'bootstrap', 'ensure_puppet'
|
||||
desc "Fix DNS resolution if bitten by the VirtualBox DNS bug"
|
||||
task :fix_dns do
|
||||
result = capture("ping -w 1 -W 1 -c 1 -q google.com; echo $?").lines.to_a.last.strip
|
||||
if result.to_i != 0
|
||||
run "#{sudo} sed -i 's#10.0.2.3#10.0.2.2#g' /etc/resolv.conf"
|
||||
result = capture("ping -w 1 -W 1 -c 1 -q google.com; echo $?").lines.to_a.last.strip
|
||||
|
||||
if result.to_i != 0
|
||||
raise StandardError.new("Unable to fix DNS to get around VirtualBox DNS bug.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
before 'apply', 'ensure_puppet', 'fix_dns'
|
||||
before 'bootstrap', 'ensure_puppet', 'fix_dns'
|
||||
end
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
class god-debian {
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
|
32
shared/additional-modules/squid/manifests/debian.pp
Normal file
32
shared/additional-modules/squid/manifests/debian.pp
Normal file
@ -0,0 +1,32 @@
|
||||
class squid::debian($version, $config_template, $error_template) {
|
||||
$squid_user = 'squid'
|
||||
$squid_group = 'squid'
|
||||
|
||||
user { $squid_user: uid => 6574 }
|
||||
|
||||
class { 'squid':
|
||||
version => $version,
|
||||
user => 'squid',
|
||||
config_template => $config_template,
|
||||
error_template => $error_template,
|
||||
require => User['squid']
|
||||
}
|
||||
|
||||
init_d_bundle { 'squid':
|
||||
init_d_prolog => template('squid/debian/init-d-prolog'),
|
||||
init_d_prerun => template('squid/debian/init-d-prerun'),
|
||||
require => Class['squid']
|
||||
}
|
||||
|
||||
exec { 'ensure-data-dir-ownership':
|
||||
command => "chown -R ${squid_user}:${squid_group} ${squid::data_dir} ${squid::log_dir}",
|
||||
path => $base::path,
|
||||
require => Class['squid']
|
||||
}
|
||||
|
||||
logrotate_d { 'squid':
|
||||
postrotate => 'service squid rotate',
|
||||
pattern => "${squid::log}/access.log"
|
||||
}
|
||||
}
|
||||
|
49
shared/additional-modules/squid/manifests/init.pp
Normal file
49
shared/additional-modules/squid/manifests/init.pp
Normal file
@ -0,0 +1,49 @@
|
||||
class squid($version, $user, $config_template, $error_template) {
|
||||
$bin = bin_path($name)
|
||||
$sbin = sbin_path($name)
|
||||
|
||||
$build_dir = build_path($name, $version)
|
||||
$log_dir = log_path($name)
|
||||
$pid = pid_path($name)
|
||||
$data_dir = data_path($name)
|
||||
$config_dir = config_path($name)
|
||||
$config = "${config_dir}/squid.conf"
|
||||
|
||||
file { [ $log_dir, $data_dir, $config_dir ]:
|
||||
ensure => directory
|
||||
}
|
||||
|
||||
build_and_install { $name:
|
||||
version => $version,
|
||||
source => "http://www.squid-cache.org/Versions/v3/3.1/squid-${version}.tar.bz2",
|
||||
configure => template('squid/configure'),
|
||||
preconfigure => template('squid/preconfigure')
|
||||
}
|
||||
|
||||
file { $config:
|
||||
content => template($config_template),
|
||||
require => Build_and_install[$name]
|
||||
}
|
||||
|
||||
$squid_start = 'service squid start'
|
||||
$squid_stop = 'service squid stop'
|
||||
|
||||
god_init { $name:
|
||||
start => $squid_start,
|
||||
stop => $squid_stop,
|
||||
restart => "${squid_stop} && ${squid_start}",
|
||||
pid_file => $pid,
|
||||
ensure => present,
|
||||
require => File[$config],
|
||||
interval => 10
|
||||
}
|
||||
|
||||
file { [
|
||||
"${data_dir}/errors/en/ERR_CANNOT_FORWARD",
|
||||
"${data_dir}/errors/templates/ERR_CANNOT_FORWARD"
|
||||
]:
|
||||
content => template($error_template),
|
||||
require => Build_and_install['squid']
|
||||
}
|
||||
}
|
||||
|
33
shared/additional-modules/squid/templates/configure
vendored
Normal file
33
shared/additional-modules/squid/templates/configure
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
--disable-maintainer-mode \
|
||||
--disable-dependency-tracking \
|
||||
--srcdir=. \
|
||||
--datadir=<%= data_dir %> \
|
||||
--sysconfdir=<%= config_dir %> \
|
||||
--enable-inline \
|
||||
--enable-async-io=24 \
|
||||
--enable-storeio=aufs \
|
||||
--enable-removal-policies="heap,lru" \
|
||||
--enable-delay-pools \
|
||||
--enable-cache-digests \
|
||||
--enable-kill-parent-hack \
|
||||
--with-dl \
|
||||
--with-aio \
|
||||
--enable-zph-qos \
|
||||
--disable-ipv6 \
|
||||
--disable-unlinkd \
|
||||
--disable-wccp \
|
||||
--disable-wccpv2 \
|
||||
--disable-ident-lookups \
|
||||
--disable-auth \
|
||||
--enable-follow-x-forwarded-for \
|
||||
--enable-arp-acl \
|
||||
--enable-esi \
|
||||
--disable-translation \
|
||||
--with-logdir=<%= log_dir %> \
|
||||
--with-pidfile=<%= pid %> \
|
||||
--with-filedescriptors=65536 \
|
||||
--with-large-files \
|
||||
--enable-linux-netfilter \
|
||||
--with-default-user=<%= user %> \
|
||||
--with-squid=<%= build_dir %> \
|
||||
--enable-ltdl-convenience
|
@ -0,0 +1 @@
|
||||
ulimit -n 65535
|
@ -0,0 +1,14 @@
|
||||
# squid3 Startup script for the SQUID HTTP proxy-cache.
|
||||
#
|
||||
# Version: @(#)squid3.rc 1.0 07-Jul-2006 luigi@debian.org
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: squid3
|
||||
# Required-Start: $network $remote_fs $syslog
|
||||
# Required-Stop: $network $remote_fs $syslog
|
||||
# Should-Start: $named
|
||||
# Should-Stop: $named
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Squid HTTP Proxy version 3.0
|
||||
### END INIT INFO
|
1
shared/additional-modules/squid/templates/preconfigure
Normal file
1
shared/additional-modules/squid/templates/preconfigure
Normal file
@ -0,0 +1 @@
|
||||
CHOST="i686-pc-linux-gnu" CFLAGS="-O2 -pipe -fomit-frame-pointer"
|
76
shared/additional-modules/squid/templates/squid-init.d
Normal file
76
shared/additional-modules/squid/templates/squid-init.d
Normal file
@ -0,0 +1,76 @@
|
||||
<%= scope.function_template('base/init-d-header') %>
|
||||
|
||||
<%= init_d_prolog %>
|
||||
<%= init_d_prerun %>
|
||||
|
||||
PATH=<%= scope::lookupvar('squid::sbin') %>:<%= scope::lookupvar('squid::bin') %>:$PATH
|
||||
BIN=<%= scope.lookupvar('squid::sbin') %>/squid
|
||||
PID=<%= scope.lookupvar('squid::pid') %>
|
||||
CONFIG=<%= scope.lookupvar('squid::config') %>
|
||||
ARGS="-YC -f $CONFIG"
|
||||
|
||||
find_cache_dir() {
|
||||
w=" " # space tab
|
||||
res=`sed -ne '
|
||||
s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
|
||||
t end;
|
||||
d;
|
||||
:end q' < $CONFIG`
|
||||
[ -n "$res" ] || res=$2
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
find_cache_type() {
|
||||
w=" " # space tab
|
||||
res=`sed -ne '
|
||||
s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
|
||||
t end;
|
||||
d;
|
||||
:end q' < $CONFIG`
|
||||
[ -n "$res" ] || res=$2
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
start() {
|
||||
cache_dir=`find_cache_dir cache_dir <%= scope.lookupvar('squid::data_dir') %>`
|
||||
cache_type=`find_cache_type cache_dir ufs`
|
||||
|
||||
#
|
||||
# Create spool dirs if they don't exist.
|
||||
#
|
||||
if [ "$cache_type" = "coss" -a -d "$cache_dir" -a ! -f "$cache_dir/stripe" ] || [ "$cache_type" != "coss" -a -d "$cache_dir" -a ! -d "$cache_dir/00" ]; then
|
||||
echo "Creating $DESC cache structure"
|
||||
$BIN -z
|
||||
fi
|
||||
|
||||
umask 027
|
||||
ulimit -n 65535
|
||||
$BIN $ARGS
|
||||
RETVAL=$?
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
PIDID=`cat $PID 2>/dev/null`
|
||||
|
||||
if [ -f $PID ]; then
|
||||
kill $PIDID
|
||||
fi
|
||||
|
||||
cnt=0
|
||||
while kill -0 $PIDID 2>/dev/null
|
||||
do
|
||||
cnt=`expr $cnt + 1`
|
||||
if [ $cnt -gt 24 ]
|
||||
then
|
||||
RETVAL=1
|
||||
return RETVAL
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
<%= scope.function_template('base/init-d-actions') %>
|
@ -1,19 +0,0 @@
|
||||
class varnish-debian($version, $store_file_mb => '1024') {
|
||||
|
||||
$varnish_user = 'varnish'
|
||||
$varnish_group = 'web'
|
||||
|
||||
user { $varnish_user:
|
||||
ensure => present,
|
||||
uid => 25678,
|
||||
groups => [ 'web' ],
|
||||
require => Group['web']
|
||||
}
|
||||
|
||||
class { varnish:
|
||||
version => $version,
|
||||
require => Package[$packages],
|
||||
store_file_mb
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
VARNISH_USERNAME=<%= varnish_user %>
|
||||
VARNISH_GROUP=<%= varnish_group %>
|
@ -1,13 +0,0 @@
|
||||
### BEGIN INIT INFO
|
||||
# Provides: varnish
|
||||
# Required-Start: $local_fs $remote_fs $network
|
||||
# Required-Stop: $local_fs $remote_fs $network
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start HTTP accelerator
|
||||
# Description: This script provides a server-side cache
|
||||
# to be run in front of a httpd and should
|
||||
# listen on port 80 on a properly configured
|
||||
# system
|
||||
### END INIT INFO
|
||||
|
@ -1,8 +1,15 @@
|
||||
define init_d_bundle($init_d_prolog, $init_d_prerun) {
|
||||
$init_d_source = "${base::share_path}/${name}/${name}-init.d"
|
||||
$share_path = "${base::share_path}/${name}"
|
||||
|
||||
file { $share_path:
|
||||
ensure => directory
|
||||
}
|
||||
|
||||
$init_d_source = "${share_path}/${name}-init.d"
|
||||
file { $init_d_source:
|
||||
content => template("${name}/${name}-init.d"),
|
||||
mode => 755
|
||||
mode => 755,
|
||||
require => File[$share_path]
|
||||
}
|
||||
|
||||
$init_d = "/etc/init.d/${name}"
|
||||
|
Loading…
Reference in New Issue
Block a user