auth0/chef-varnish

Name: chef-varnish

Owner: Auth0

Description: Development repository for Chef Cookbook varnish

Forked from: sous-chefs/varnish

Created: 2016-03-17 17:08:37.0

Updated: 2017-02-07 21:18:02.0

Pushed: 2016-03-18 17:15:52.0

Homepage: http://supermarket.getchef.com/cookbooks/varnish

Size: 162

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Circle CI

varnish Cookbook

Installs and configures varnish.

Requirements
chef-client
Platforms

Tested on:

Attributes

If you don't specify your own vcl_conf file, then these attributes are used in the cookbook default.vcl template:

Recipes
default

Installs the varnish package, manages the default varnish configuration file, and the init script defaults file.

repo

If placed before the default recipe in the run list, the official Varnish project apt repository will offer access to more version and platform support.

Usage

On systems that need a high performance caching server, use recipe[varnish]. Additional configuration can be done by modifying the default.vcl.erb and default.erb templates.

If running on a Redhat derivative then you may need to include yum-epel as it provides the jemalloc dependency that varnish needs

Resources

See the distro_install and vendor_install recipes for examples of these resources in action.

varnish_install

Installs Varnish with the default configuration supplied by the package.

The :install action handles package installation. By default, it will install Varnish from your distro repositories. If you set the vendor_repo parameter to true, then it will install Varnish from the varnish-cache repositories.

Parameters

| Name | Type | Default Value | ——-|——|—————| | package_name | string | 'varnish' | | vendor_repo | true or false | false | | vendor_version | string | '4.0' |

Actions Examples

Install from the OS distribution :

ish_install 'default' do
ckage_name 'varnish'
ndor_repo false

Install version 4 from the vendor :

ish_install 'default' do
ckage_name 'varnish'
ndor_repo true
ndor_version '4.0'

varnish_default_config

Configures the Varnish service. If you do not include this, the config files that come with your distro package will be used instead.

| Name | Type | Default Value | |——|——|—————| |start_on_boot | true or false | true | |max_open_files | integer | 131_072 | | max_locked_memory | integer | 82_000 | | instance_name | string | nil | | listen_address | string | nil | | listen_port | integer | 6081 | | admin_listen_address | string | '127.0.0.1' | | admin_plisten_port | integer | 6082 | | user | string | 'varnish' | | group | string | 'varnish' | | ttl | integer | 120 | | storage | 'malloc' or 'file' | 'file' | | file_storage_path | string | '/var/lib/varnish/%s_storage.bin' where %s is replaced with the resource name| | file_storage_size | string | '1G' | | malloc_size | string | nil | | path_to_secret | string | '/etc/varnish/secret' |

You can also send a hash to parameters which will add additional parameters to the varnish daemon via the -p option. The default hash is:

hread_pools' => '4',
hread_pool_min' => '5',
hread_pool_max' => '500',
hread_pool_timeout' => '300' }
Actions Example

Configure some parameters on the Varnish service :

ish_default_config 'default' do
art_on_boot true
x_open_files 131_072
x_locked_memory 82_000
sten_address nil
sten_port 6081
th_to_vcl '/etc/varnish/default.vcl'
min_listen_address '127.0.0.1'
min_listen_port 6082
er 'varnish'
oup 'varnish'
l 120
orage 'malloc'
lloc_size "#{(node['memory']['total'][0..-3].to_i * 0.75).to_i}K"
rameters(thread_pools: '4',
         thread_pool_min: '5',
         thread_pool_max: '500',
         thread_pool_timeout: '300')
th_to_secret '/etc/varnish/secret'

varnish_default_vcl

| Name | Type | Default Value | |——|——|—————| | backend_host | string | 'localhost' | backend_port | integer | 8080 | | vcl_source | string | 'lib_default.vcl.erb' | | vcl_cookbook | string | 'varnish' | | vcl_parameters | hash | {} |

You can specify an alternative template (e.g. in a wrapper cookbook) and send a hash of any parameters you need to that template.

Example

Set a backend to example.com:80 :

ish_default_vcl 'default' do
ckend_host 'example.com'
ckend_port 80

Actions
varnish_log

Configures varnishlog or varnishncsa service. You can define both logfiles by calling varnish_log more than once. You can install logrotate config files if you wish as well.

| Name | Type | Default Value | |——|——|—————| | file_name | string | '/var/log/varnish/varnishlog.log' | | pid | string | '/var/run/varnishlog.pid' | | log_format | 'varnishlog' or 'varnishncsa' | 'varnishlog' | | ncsa_format_string | string | '%h|%l|%u|%t|\"%r\"|%s|%b|\"%{Referer}i\"|\"%{User-agent}i\"' | instance_name | string | nil | | logrotate | true or false | true | | logrotate_path | string | '/etc/logrotate.d' |

Actions Examples

Configure varnish logs with log rotation :

ish_log 'default' do
le_name '/var/log/varnish/varnishlog.log'
d '/var/run/varnishlog.pid'
g_format 'varnishlog'
grotate true
grotate_path '/etc/logrotate.d'

Configure ncsa logs with a specific output format and without log rotation :

ish_log 'default_ncsa' do
le_name '/var/log/varnish/varnishncsa.log'
d '/var/run/varnishncsa.pid'
g_format 'varnishncsa'
sa_format_string '%h|%l|%u|%t|\"%r\"|%s|%b|\"%{Referer}i\"|\"%{User-agent}i\"'
grotate false

License & Authors
right 2008-2009, Joe Williams <joe@joetify.com>
right 2014. Patrick Connolly <patrick@myplanetdigital.com>
right 2015. Rackspace, US Inc.

nsed under the Apache License, Version 2.0 (the "License");
may not use this file except in compliance with the License.
may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

ss required by applicable law or agreed to in writing, software
ributed under the License is distributed on an "AS IS" BASIS,
OUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
the License for the specific language governing permissions and
tations under the License.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.