From 22680a3510bcbac6c7f4a3f4efe7ad033529ae70 Mon Sep 17 00:00:00 2001 From: Udo Waechter Date: Tue, 4 Nov 2014 12:53:37 +0100 Subject: [PATCH] varnish base config, crude --- manifests/init.pp | 35 ++++++-- templates/etc_default_varnish.erb | 114 ++++++++++++++++++++++++++ templates/etc_default_varnishlog.erb | 13 +++ templates/etc_default_varnishncsa.erb | 16 ++++ 4 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 templates/etc_default_varnish.erb create mode 100644 templates/etc_default_varnishlog.erb create mode 100644 templates/etc_default_varnishncsa.erb diff --git a/manifests/init.pp b/manifests/init.pp index 2e2fc16..a480bc9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,13 +1,30 @@ class varnish { - package { 'varnish': require => Class['packages::backports'], } + package { 'varnish': require => Class['packages::backports'], } -# ncsa loggin: - service { ['varnishncsa', 'varnishlog']: - ensure => running, - enable => true, - require => Package['varnish'] - } + # ncsa loggin: + service { ['varnish', 'varnishncsa', 'varnishlog']: + ensure => running, + enable => true, + require => Package['varnish'] + } - class{'logshipper::app::varnishncsa': } - ganglia::module::python_git { 'varnish': } + file { + '/etc/default/varnish': + content => template('varnish/etc_default_varnish.erb'), + notify => Service['varnish']; + + '/etc/default/varnishnsca': + content => template('varnish/etc_default_varnishncsa.erb'), + notify => Service['varnishncsa']; + + '/etc/default/varnishlog': + content => template('varnish/etc_default_varnishlog.erb'), + notify => Service['varnishlog']; + } + + class { 'logshipper::app::varnishncsa': + require => File['/etc/default/varnishnsca']; + } + + ganglia::module::python_git { 'varnish': } } diff --git a/templates/etc_default_varnish.erb b/templates/etc_default_varnish.erb new file mode 100644 index 0000000..af440a3 --- /dev/null +++ b/templates/etc_default_varnish.erb @@ -0,0 +1,114 @@ +########## PUPPET MANAGED ###################### + +# Configuration file for varnish +# +# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK +# to be set from this shell script fragment. +# +# Note: If systemd is installed, this file is obsolete and ignored. You will +# need to copy /lib/systemd/system/varnish.service to /etc/systemd/system/ and +# edit that file. + +# Should we start varnishd at boot? Set to "no" to disable. +START=yes + +# Maximum number of open files (for ulimit -n) +NFILES=131072 + +# Maximum locked memory size (for ulimit -l) +# Used for locking the shared memory log in memory. If you increase log size, +# you need to increase this number as well +MEMLOCK=82000 + +# Default varnish instance name is the local nodename. Can be overridden with +# the -n switch, to have more instances on a single server. +# INSTANCE=$(uname -n) + +# This file contains 4 alternatives, please use only one. + +## Alternative 1, Minimal configuration, no VCL +# +# Listen on port 6081, administration on localhost:6082, and forward to +# content server on localhost:8080. Use a 1GB fixed-size cache file. +# +# DAEMON_OPTS="-a :6081 \ +# -T localhost:6082 \ +# -b localhost:8080 \ +# -u varnish -g varnish \ +# -S /etc/varnish/secret \ +# -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" + + +## Alternative 2, Configuration with VCL +# +# Listen on port 6081, administration on localhost:6082, and forward to +# one content server selected by the vcl file, based on the request. Use a 1GB +# fixed-size cache file. +# +DAEMON_OPTS="-a :80 \ + -T localhost:6082 \ + -f /etc/varnish/default.vcl \ + -S /etc/varnish/secret \ + -s malloc,1500m \ + -p thread_pool_min=500 -p thread_pool_max=2048 \ + -p session_max=10000" + + #-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" + +## Alternative 3, Advanced configuration +# +# See varnishd(1) for more information. +# +# # Main configuration file. You probably want to change it :) +# VARNISH_VCL_CONF=/etc/varnish/default.vcl +# +# # Default address and port to bind to +# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify +# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets. +# VARNISH_LISTEN_ADDRESS= +# VARNISH_LISTEN_PORT=6081 +# +# # Telnet admin interface listen address and port +# VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 +# VARNISH_ADMIN_LISTEN_PORT=6082 +# +# # The minimum number of worker threads to start +# VARNISH_MIN_THREADS=1 +# +# # The Maximum number of worker threads to start +# VARNISH_MAX_THREADS=1000 +# +# # Idle timeout for worker threads +# VARNISH_THREAD_TIMEOUT=120 +# +# # Cache file location +# VARNISH_STORAGE_FILE=/var/lib/varnish/$INSTANCE/varnish_storage.bin +# +# # Cache file size: in bytes, optionally using k / M / G / T suffix, +# # or in percentage of available disk space using the % suffix. +# VARNISH_STORAGE_SIZE=1G +# +# # File containing administration secret +# VARNISH_SECRET_FILE=/etc/varnish/secret +# +# # Backend storage specification +# VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}" +# +# # Default TTL used when the backend does not specify one +# VARNISH_TTL=120 +# +# # DAEMON_OPTS is used by the init script. If you add or remove options, make +# # sure you update this section, too. +# DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ +# -f ${VARNISH_VCL_CONF} \ +# -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ +# -t ${VARNISH_TTL} \ +# -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \ +# -S ${VARNISH_SECRET_FILE} \ +# -s ${VARNISH_STORAGE}" +# + + +## Alternative 4, Do It Yourself +# +# DAEMON_OPTS="" \ No newline at end of file diff --git a/templates/etc_default_varnishlog.erb b/templates/etc_default_varnishlog.erb new file mode 100644 index 0000000..d9f024c --- /dev/null +++ b/templates/etc_default_varnishlog.erb @@ -0,0 +1,13 @@ +#### PUPPET MANAGED ############## +# Configuration file for varnishlog +# +# Note: If systemd is installed, this file is obsolete and ignored. You will +# need to copy /lib/systemd/system/varnishlog.service to /etc/systemd/system/ +# and edit that file. +# +# Uncomment this to enable logging for varnish. Please make sure you have +# enough disk space for significant amounts of log data. To disable logging, +# set the variable to "0", "no", or leave it unset. +# +# Varnish log format, to be used by "varnishlog" or "varnishncsa" +VARNISHLOG_ENABLED=1 \ No newline at end of file diff --git a/templates/etc_default_varnishncsa.erb b/templates/etc_default_varnishncsa.erb new file mode 100644 index 0000000..0f6f86e --- /dev/null +++ b/templates/etc_default_varnishncsa.erb @@ -0,0 +1,16 @@ +####### PUPPET MANAGED ####################### +# Configuration file for varnishncsa +# +# Note: If systemd is installed, this file is obsolete and ignored. You will +# need to copy /lib/systemd/system/varnishncsa.service to /etc/systemd/system/ +# and edit that file. +# +# Uncomment this to enable logging for varnish. Please make sure you have +# enough disk space for significant amounts of log data. To disable logging, +# set the variable to "0", "no", or leave it unset. +# +FORMAT="%{Host}i %h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" %{Varnish:time_firstbyte}x %{Varnish:hitmiss}x %{Varnish:handling}x %{X-Varnish}o" +#FORMAT="%{X-Varnish}o %{Varnish:handling}x %D" +DAEMON_OPTS="-a -w ${LOGFILE} -D -P ${PIDFILE}" +# NCSA log format, to be used by HTTP log analyzers +VARNISHNCSA_ENABLED=1