diff --git a/lib/puppet-standalone-mashup/capistrano/vagrant.rb b/lib/puppet-standalone-mashup/capistrano/vagrant.rb index 22cf6fd..0357d55 100644 --- a/lib/puppet-standalone-mashup/capistrano/vagrant.rb +++ b/lib/puppet-standalone-mashup/capistrano/vagrant.rb @@ -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 diff --git a/shared/additional-modules/god-debian/manifests/init.pp b/shared/additional-modules/god-debian/manifests/init.pp deleted file mode 100644 index c3a2df6..0000000 --- a/shared/additional-modules/god-debian/manifests/init.pp +++ /dev/null @@ -1,3 +0,0 @@ -class god-debian { -} - diff --git a/shared/additional-modules/ruby-debian/manifests/init.pp b/shared/additional-modules/ruby-debian/manifests/init.pp deleted file mode 100644 index 8b13789..0000000 --- a/shared/additional-modules/ruby-debian/manifests/init.pp +++ /dev/null @@ -1 +0,0 @@ - diff --git a/shared/additional-modules/squid/manifests/debian.pp b/shared/additional-modules/squid/manifests/debian.pp new file mode 100644 index 0000000..571978c --- /dev/null +++ b/shared/additional-modules/squid/manifests/debian.pp @@ -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" + } +} + diff --git a/shared/additional-modules/squid/manifests/init.pp b/shared/additional-modules/squid/manifests/init.pp new file mode 100644 index 0000000..889e600 --- /dev/null +++ b/shared/additional-modules/squid/manifests/init.pp @@ -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'] + } +} + diff --git a/shared/additional-modules/squid/templates/configure b/shared/additional-modules/squid/templates/configure new file mode 100644 index 0000000..9b492c9 --- /dev/null +++ b/shared/additional-modules/squid/templates/configure @@ -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 diff --git a/shared/additional-modules/squid/templates/debian/init-d-prerun b/shared/additional-modules/squid/templates/debian/init-d-prerun new file mode 100644 index 0000000..75c7cb0 --- /dev/null +++ b/shared/additional-modules/squid/templates/debian/init-d-prerun @@ -0,0 +1 @@ +ulimit -n 65535 diff --git a/shared/additional-modules/squid/templates/debian/init-d-prolog b/shared/additional-modules/squid/templates/debian/init-d-prolog new file mode 100644 index 0000000..975d79d --- /dev/null +++ b/shared/additional-modules/squid/templates/debian/init-d-prolog @@ -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 diff --git a/shared/additional-modules/squid/templates/preconfigure b/shared/additional-modules/squid/templates/preconfigure new file mode 100644 index 0000000..0e0c1a0 --- /dev/null +++ b/shared/additional-modules/squid/templates/preconfigure @@ -0,0 +1 @@ +CHOST="i686-pc-linux-gnu" CFLAGS="-O2 -pipe -fomit-frame-pointer" diff --git a/shared/additional-modules/squid/templates/squid-init.d b/shared/additional-modules/squid/templates/squid-init.d new file mode 100644 index 0000000..d9e7e5f --- /dev/null +++ b/shared/additional-modules/squid/templates/squid-init.d @@ -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') %> diff --git a/shared/additional-modules/varnish-debian/manifests/init.pp b/shared/additional-modules/varnish-debian/manifests/init.pp deleted file mode 100644 index 188fde8..0000000 --- a/shared/additional-modules/varnish-debian/manifests/init.pp +++ /dev/null @@ -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 - } -} - diff --git a/shared/additional-modules/varnish-debian/templates/init_d_prerun b/shared/additional-modules/varnish-debian/templates/init_d_prerun deleted file mode 100644 index 9e726b9..0000000 --- a/shared/additional-modules/varnish-debian/templates/init_d_prerun +++ /dev/null @@ -1,2 +0,0 @@ -VARNISH_USERNAME=<%= varnish_user %> -VARNISH_GROUP=<%= varnish_group %> diff --git a/shared/additional-modules/varnish-debian/templates/init_d_prolog b/shared/additional-modules/varnish-debian/templates/init_d_prolog deleted file mode 100644 index fea17dd..0000000 --- a/shared/additional-modules/varnish-debian/templates/init_d_prolog +++ /dev/null @@ -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 - diff --git a/shared/modules/init_d_bundle/manifests/init.pp b/shared/modules/init_d_bundle/manifests/init.pp index c625dfa..ffbcb1e 100644 --- a/shared/modules/init_d_bundle/manifests/init.pp +++ b/shared/modules/init_d_bundle/manifests/init.pp @@ -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}"