cookbook 'varnish', '= 3.3.1'
varnish
(58) Versions
3.3.1
-
-
5.0.20
-
5.0.19
-
5.0.18
-
5.0.17
-
5.0.16
-
5.0.15
-
5.0.14
-
5.0.13
-
5.0.12
-
5.0.11
-
5.0.10
-
5.0.9
-
5.0.8
-
5.0.7
-
5.0.6
-
5.0.5
-
5.0.4
-
5.0.3
-
5.0.2
-
5.0.1
-
5.0.0
-
4.1.2
-
4.1.1
-
4.1.0
-
4.0.1
-
3.5.0
-
3.4.0
-
3.3.1
-
3.3.0
-
3.1.0
-
3.0.1
-
3.0.0
-
2.5.0
-
2.4.0
-
2.3.0
-
2.2.2
-
2.2.1
-
2.2.0
-
2.1.1
-
2.1.0
-
2.0.0
-
1.0.2
-
1.0.1
-
1.0.0
-
0.9.18
-
0.9.17
-
0.9.16
-
0.9.15
-
0.9.14
-
0.9.13
-
0.9.12
-
0.9.10
-
0.9.8
-
0.9.6
-
0.9.4
-
0.9.2
-
0.9.1
-
0.7.0
Follow60
- 5.0.20
- 5.0.19
- 5.0.18
- 5.0.17
- 5.0.16
- 5.0.15
- 5.0.14
- 5.0.13
- 5.0.12
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.1
- 3.5.0
- 3.4.0
- 3.3.1
- 3.3.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.0.2
- 1.0.1
- 1.0.0
- 0.9.18
- 0.9.17
- 0.9.16
- 0.9.15
- 0.9.14
- 0.9.13
- 0.9.12
- 0.9.10
- 0.9.8
- 0.9.6
- 0.9.4
- 0.9.2
- 0.9.1
- 0.7.0
Installs and configures varnish
cookbook 'varnish', '= 3.3.1', :supermarket
knife supermarket install varnish
knife supermarket download varnish
varnish Cookbook
Configures varnish.
Requirements
chef-client
- Requires chef-client 12.5 and above.
- If you are using chef-client <12.9 and the
debian
platform family you will need to pin to the 5.X release of theapt
cookbook.
Platforms
Tested on the platforms below with distro installs and upstream Varnish packaging versions 3, 4.0, and 4.1 unless otherwise noted.
- Ubuntu 14.04
- Ubuntu 16.04
- Tested with Ubuntu's 16.04 distribution (version 4.1).
- CentOS 6.8
- Tested with 3, 4.0, and 4.1 (distro version is 2.0 which is not supported)
- CentOS 7.3
- Tested with 4.1 and the CentOS 7 distrubution version
- 4.0 only works with the distro version (https://github.com/sous-chefs/varnish/issues/142)
Other versions may work but require pinning to the correct version which isn't included in this cookbook currently.
Global Attributes
These attributes used as defaults for both resources and the varnish::configure
cookbook but can be also overridden with other attributes and resource properties described later.
* node['varnish']['conf_path']
- location of the default
file that controls the varnish init script on Debian/Ubuntu systems.
* node['varnish']['reload_cmd']
- location of the varnish reload script used by the systemd config file. This is not used for initd currently.
* node['varnish']['conf_source']
- template file source to use for the default
varnish init config.
* node['varnish']['conf_cookbook']
- template cookbook source to use for the default
varnish init config.
* node['varnish']['major_version']
- the major version of varnish to install. Can be 3.0, 4.0, 4.1, and default's to 4.1.
Recipes
default
This is not used currently but reserved for minimal configuration needed for all the resources/recipes to work correctly.
configure
Installs the varnish package, manages the varnish configuration file, and the init script defaults file.
Usage
You can either use include the varnish::configure recipe and configure the setup using the recipe attributes described below or include varnish::default and use the resources directly.
If running on a Redhat derivative then you may need to include yum-epel as it provides the jemalloc dependency that varnish needs.
Configure Recipe Attributes
Common Settings
The configure recipe uses the resources below to get varnish and varnishlog installed and running from the vendor repo. The recipe will work without any additional configuration however there is a few common attributes that you may want to set.
-
node['varnish']['configure']['repo']['action']
- Affects the vendor repo resource. Can be set to:nothing
to skip and use the systems package otherwise the default is to:configure
it. -
node['varnish']['configure']['package']['version']
- Specific varnish version to pass to the package resource. Default is to install the latest available version for the currentnode['varnish']['major_version']
. -
node['varnish']['configure']['log']['action']
- Affects the varnish_log resource. Can be set to:nothing
to skip and not set up logging otherwise the default is to:configure
it. -
node['varnish']['configure']['config']['listen_port']
- Port number to listen on for requests to varnish. Defaults to 6081. -
node['varnish']['configure']['vcl_template']['source']
- Name for default vcl template. Defaults to default.vcl.erb. -
node['varnish']['configure']['vcl_template']['cookbook']
- Name of the cookbook for the default vcl template. Uses this varnish cookbook by default.
If you are using the default vcl_template then backend_port and backend_host are configurable through these parameters.
* node['varnish']['configure']['vcl_template']['variables']['config']['backend_port']
- The default vcl_template backend port (default: 80).
* node['varnish']['configure']['vcl_template']['variables']['config']['backend_host']
- The default vcl_template backend_host (default: 127.0.0.1).
Any resource property in the varnish::configure
recipe can be configured. The keys under the namespace's listed below will map to the property name. Refer to the resource documentation for details on all the properties.
Resource | Attribute Namespace |
---|---|
varnish_repo 'configure' |
node['varnish']['configure']['repo'] |
package 'varnish' |
node['varnish']['configure']['package'] |
service 'varnish' |
node['varnish']['configure']['service'] |
varnish_config 'default' |
node['varnish']['configure']['config'] |
vcl_template 'default' |
node['varnish']['configure']['vcl_template'] |
varnish_log 'default' |
node['varnish']['configure']['log'] |
varnish_log 'ncsa' |
node['varnish']['configure']['ncsa'] |
Recipe Example's
Use the systems varnish package and skip enabling the varnishlog daemon :
node.override['varnish']['configure']['repo']['action'] = :nothing
node.override['varnish']['configure']['log']['action'] = :nothing
include_recipe 'varnish::configure'
Use custom.vcl.erb
template in my_cookbook
and configure varnish to listen on port 80:
node.override['varnish']['configure']['config']['listen_port'] = 80
node.override['varnish']['configure']['vcl_template']['source'] = 'custom.vcl.erb'
node.override['varnish']['configure']['vcl_template']['cookbook'] = 'my_cookbook'
include_recipe 'varnish::configure'
Resources
See the example resource recipe section to see how to use these in your recipe.
varnish_repo
Configure's the varnish vendor repo.
Will configure the varnish repo specified by node['varnish']['major_version']
which can be overridden with the major_version property.
Parameters
Name | Type | Default Value |
---|---|---|
major_version |
3.0 , 4.0 , or 4.1
|
node['varnish']['major_version'] (4.1 by default) |
fetch_gpg_key |
true or false
|
true for debian distro's otherwise false (rpm packages are not signed) |
Actions
-
:configure
- Configures the varnish vendor repo.
Examples
Configures the varnish 3.0 vendor repo :
varnish_repo 'varnish' do
major_version 3.0
end
varnish_config
Configures the Varnish service through the defaults or systemd init file. If you do not include this, the config
files that come with your distro package will be used instead.
Name | Type | Default Value |
---|---|---|
conf |
string |
node['varnish']['conf_source'] |
start_on_boot |
true or false
|
true |
max_open_files |
integer | 131_072 |
max_locked_memory |
integer | 82_000 |
major_version |
3.0 , 4.0 , or 4.1
|
node['varnish']['major_version'] |
instance_name |
string |
`hostname` ]` |
listen_address |
string | nil |
listen_port |
integer | 6081 |
admin_listen_address |
string | '127.0.0.1' |
admin_listen_port |
integer | 6082 |
user |
string | 'varnish' |
group |
string | 'varnish' |
ccgroup |
string | nil |
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_percent |
Integer | 33 |
malloc_size |
string | nil |
path_to_secret |
string | '/etc/varnish/secret' |
reload_cmd |
string | node['varnish']['reload_cmd'] |
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:
{ 'thread_pools' => '4',
'thread_pool_min' => '5',
'thread_pool_max' => '500',
'thread_pool_timeout' => '300' }
Actions
-
:configure
- Creates the varnish configuration file from template.
Example
Configure some parameters on the Varnish service :
varnish_config 'default' do
listen_address '0.0.0.0'
listen_port 80
storage 'malloc'
malloc_percent 33
end
vcl_template
Name | Type | Default Value |
---|---|---|
vcl_name |
string | resource name |
source |
string | "#{::File.basename(vcl_name)}.erb" |
cookbook |
string | nil |
owner |
string | 'root' |
group |
string | 'root' |
mode |
string or integer | '0644' |
variables |
hash | {} |
varnish_dir |
string | '/etc/varnish' |
vcl_path |
string | ::File.join(varnish_dir, vcl_name) |
Example
Create vcl file at '/etc/varnish/backends.vcl' using the template at 'templates/default/backends.vcl.erb' and pass it some variables:
vcl_template 'backends.vcl' do
variables(
backends_ids: Array(1..16),
env: 'live',
)
end
Actions
-
:configure
- Creates a vcl file from a template and refreshes varnish. -
:unconfigure
- Removes the vcl file and refreshes varnish.
vcl_file
Name | Type | Default Value |
---|---|---|
vcl_name |
string | resource name |
source |
string | ::File.basename(vcl_name)" |
cookbook |
string | nil |
owner |
string | 'root' |
group |
string | 'root' |
mode |
string or integer | '0644' |
varnish_dir |
string | '/etc/varnish' |
vcl_path |
string | ::File.join(varnish_dir, vcl_name) |
Example
Create vcl file at '/etc/varnish/default.vcl' using the file at 'files/default/default.vcl':
vcl_file 'default.vcl'
Actions
-
:configure
- Creates a vcl file from the cookbook and refreshes varnish. -
:unconfigure
- Removes the vcl file and refreshes varnish.
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 |
instance_name |
string | nil |
logrotate |
true or false
|
true for vanishlog, false for varnishncsa |
major_version |
3.0 , 4.0 , or 4.1
|
currently installed major version |
logrotate_path |
string |
'/etc/logrotate.d' if varnishncsa is used otherwise nil
|
Actions
-
:configure
- configures thevarnishlog
orvarnishncsa
service.
Examples
Configure varnishlog service :
varnish_log 'default'
Configure varnishncsa service :
varnish_log 'default_ncsa' do
log_format 'varnishncsa'
end
Resource Recipe Example
Install and configure varnish 4.1 using vcl config default.vcl in the current cookbook as well as a backend.vcl template.
include_recipe 'apt'
include_recipe 'varnish::default'
varnish_repo 'configure' do
major_version 4.1
end
package 'varnish'
service 'varnish' do
action [:enable, :start]
end
varnish_config 'default' do
listen_address '0.0.0.0'
listen_port 80
storage 'malloc'
malloc_percent 33
end
vcl_template 'backends.vcl' do
source 'backends.vcl.erb'
variables(
backends_ids: Array(1..16),
env: 'live',
)
end
vcl_file 'default.vcl'
# varnishlog
varnish_log 'default'
# varnishncsa
varnish_log 'default_ncsa' do
log_format 'varnishncsa'
end
License & Authors
- Author:: Joe Williams joe@joetify.com
- Author:: Lew Goettner lew@goettner.net
- Author:: Matthew Thode matt.thode@rackspace.com
- Author:: Matt Barlow matt.barlow@rackspace.com
- Contributor:: Patrick Connolly patrick@myplanetdigital.com
- Contributor:: Antonio Fernández Vara antoniofernandezvara@gmail.com
- Contributor:: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
Copyright 2008-2009, Joe Williams <joe@joetify.com> Copyright 2014. Patrick Connolly <patrick@myplanetdigital.com> Copyright 2015. Rackspace, US Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Dependent cookbooks
apt >= 2.4 |
build-essential >= 0.0.0 |
chef-sugar >= 0.0.0 |
yum >= 3.0 |
yum-epel >= 0.0.0 |
Contingent cookbooks
varnish Cookbook CHANGELOG
This file is used to list changes made in each version of the varnish cookbook.
v3.3.1
- Remove upper bound on yum cookbook dependency. #147
- Add repo_gpgcheck to redhat varnish repo. #145
v3.3.0
- Updates to the new upstream varnish repo. https://github.com/sous-chefs/varnish/issues/140
- Deprecates using the upstream varnish 4 repo on CentOS 7 (distro version still works). https://github.com/sous-chefs/varnish/issues/142
v3.2.0
- Links /etc/sysconfig/varnishlog and varnishncsa to defaults file in /etc/default. Fixes https://github.com/sous-chefs/varnish/issues/125.
- Fixes default varnishncsa format string (double quotes where getting added).
- Fixes an conflict when using both varnishlog and varnishncsa.
- Fixes distro_install integration tests. https://github.com/sous-chefs/varnish/issues/126
- Reverts the removal of reload-vcl since this is not fixed upstream in ubuntu's system packages yet.
v3.1.0
- Varnish expects the varnish instance name to be
hostname
by default however this is sometimes different thenhostname -s
which is used byohai's hostname
. This seemed to only be an issue on CentOS 7.2. - Use /etc/varnish/varnish.params for systemd init file. This is what the package uses and I think will remove some confusion about how settings are set. #103
- Remove /usr/share/varnish/reload-vcl on debian. This was added to support the '-j' option in varnish 4.1 however it has been fixed upstream.
- including yum-epel for centos
- Removing old testing files(CircleCi, kitchen-rackspace, rake) and replacing with (TravisCI, kitchen-dokken, delivery).
- adding integration testing in ci.
v3.0.0
- Move recipes in default to custom resources / Move recipe and lwrp defaults config to custom resource
- Remove unused properties
- Don't append '.vcl' to file name
- Fix percent_of_total_mem function
- Include default recipe in integrations tests
- Add configure recipe
- Don't use default recipe to install/setup varnish
- Don't fetch the repository key over insecure HTTP
v2.4.0
- Add additional attributes to allow use of template source from a wrapper cookbook
- Move define_systemd_daemon_reload to helpers (#97)
- Fix Chef::Exceptions::ChecksumMismatch error
- Set Ruby vers to 2.2.3 to satisfy ruby_dep requirements (#104)
v2.3.0
- Fix chef 12.5 compatibility. This required a bunch of workarounds we should fix later.
v2.2.2
- #86 - Removed monkey patching of service providers
v2.2.1
- Fix a bug in the monkey patched service resource, so that the changes needed for Varnish don't affect other services. #83.
- Update docs, Rakefile, standards. #79.
- Add additional examples to the documentation. #74.
v2.2.0
Fix default storage bug. Specify a default file storage location, as one is required with file backend, fixes #72. Adjust template for default configuration of varnish so that it won't do the file backend without a path, since that's illegal syntax.
Cause varnish reload to happen after restart. Delayed notifications are queued up in order. In this case, it makes sense for the reload to happen after the restart.
Switch from service restart to service reload. The varnish_default_vcl has been updated to perform a service reload instead of a service restart. This will prevent the cache from being cleared when a reload of the vcl file is enough.
v2.1.1
- Fixes #56. The apt resource may not be included, so no need to run a notification on it.
v1.2.0
- Make resource_name compatible with older Chef. Switch from passing an argument into resource_name to using the assignment operator '='. This will make resource_name compatible with older versions of Chef.
v1.1.0 (2015-02-16)
- Created libraries, to eventually replace recipe functionality, currently can be used along side recipes
- Added CircleCI support for automated testing
- Added logrotate support
- Added varnish(log|nsca) support
v0.9.12 (2014-03-12)
- [COOK-4368] - Improve documentation to include all attributes
v0.9.10
Bug
- COOK-3531 - Fix default instance name
v0.9.8
Improvement
- COOK-3095 - Add MiniTest Chef Handler and Test Kitchen
v0.9.6
Bug
- [COOK-2892]: Varnish restarts when vcl is updated instead of reloading
v0.9.4
- [COOK-1261] - fix issues with default.vcl handling
v0.9.0
- [COOK-873] - full daemon configuration through attributes
- [COOK-1091] - fix path for default.vcl, via COOK-873
- [COOK-1162] - add apt_repo recipe for using official varnish repository
v0.8.0
- Current public release.
Collaborator Number Metric
3.3.1 passed this metric
Contributing File Metric
3.3.1 passed this metric
Foodcritic Metric
3.3.1 passed this metric
License Metric
3.3.1 passed this metric
No Binaries Metric
3.3.1 passed this metric
Testing File Metric
3.3.1 passed this metric
Version Tag Metric
3.3.1 passed this metric
3.3.1 passed this metric
3.3.1 passed this metric
Foodcritic Metric
3.3.1 passed this metric
License Metric
3.3.1 passed this metric
No Binaries Metric
3.3.1 passed this metric
Testing File Metric
3.3.1 passed this metric
Version Tag Metric
3.3.1 passed this metric
3.3.1 passed this metric
3.3.1 passed this metric
No Binaries Metric
3.3.1 passed this metric
Testing File Metric
3.3.1 passed this metric
Version Tag Metric
3.3.1 passed this metric
3.3.1 passed this metric
3.3.1 passed this metric
Version Tag Metric
3.3.1 passed this metric
3.3.1 passed this metric