Version information
This version is compatible with:
Start using this module
Add this module to your Puppetfile:
mod 'chartbeat-varnish', '1.0.2'
Learn more about managing modules with a PuppetfileDocumentation
Varnish
Puppet module for varnish.
Example usage
The base class just installs varnish and stops the service. This is because varnish services are created in the varnish::instance defined type.
If you just want to install the varnish package but don't want it running:
include varnish
If you want to modify which version of varnish you want to run, there are currently two supported methods.
Class Parameters
class { 'varnish' :
package_ensure => '1.2.3',
}
Hiera
---
varnish::package_ensure: '1.2.3'
Include with default parameters:
varnish::instance { 'instance0' : }
Include with multiple different storage types:
varnish::instance { 'instance0' :
storage_file => ['file,/mnt/varnish/instance0/varnish_storage.bin,70%',
'persistent,/data/varnish/varnish_storage.bin,20%']
}
The varnish::instance type is fully configurable. All of the varnish options are available as parameters. If, for instance, you want to increase the thread pool max size you could specify that as a param.
All of the parameters are set to the defaults as defined in varnishd(1)
varnish::instance { 'instance0' :
thread_pool_max => '1500',
}
VMODS
The varnish::instance class supports installing vmods. Currently it expects them to be installed via APT. There are plans to support building it from source, but that would require a custom provider which is not yet built.
To ensure that a given varnish::instance has the throttle vmod installed that it needs:
varnish::instance { 'instance0' :
vmods => ['libvmod-throttle'],
}
Repo
This varnish module currently uses the public repo.varnish-cache.org debian repository. If you want to use another repo, you can do it like the varnish package above, with class parameters or hiera.
Class Parameters
class { 'varnish' :
apt_location => 'http://some.other.repo',
apt_repos => 'main restricted universe',
...
}
Hiera
---
varnish::apt_location: 'http://some.other/repo'
varnish::apt_repos: 'repo-name'
varnish::apt_key: 'XXXXXX'
varnish::key_source: 'http://some.other/key.txt'
varnish::apt_include_src: false
Configs
The varnish::instance type ships with a pretty simple config. You can pass in your own vcl config by just specifying the following:
varnish::instance { 'instance0' :
vcl_conf => 'puppet:///path/to/config/file.vcl',
}
Or if your config is a template, you can do that as well:
varnish::instance { 'instance0' :
vcl_conf => 'path/to/template/file.vcl.erb',
}
Note that if you pass in your own config, you'll have to handle the backend configuration, backend probes, vmod imports, acls yourself
Extra conf
There is an extra_conf parameter that you can use as a way to customize the default vcl conf further, but also retaining much of the scaffolding present in the default vcl conf. When multiple subroutines are defined in varnish, varnish will concatentate them together, for example:
vcl_recv {
if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
}
vcl_recv {
# Serve up stale data for this long
set req.grace = 6s;
}
Will result in the following compiled version:
vcl_recv {
if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
# Serve up stale data for this long
set req.grace = 6s;
}
As long as a return(SUBROUTINE) is not hit somewhere higher up, processing will continue on through the vcl. The default vcl conf that ships with this module has no return statements (except for the PURGE request) so you can safely append your custom vcl configurations by just passing them in as extra_conf.
varnish::instance { 'instance0' :
extra_conf => 'puppet:///path/to/extra/conf.vcl'
}
Testing
This module uses rspec-puppet, rspec-puppet-system and rspec-system-serverspec. To test, install the required gems through Bundler.
$ git clone git://github.com/chartbeat/puppet-varnish.git
$ cd puppet-varnish
$ bundle install
$ bundle exec rake spec
$ bundle exec rake acceptance
To perform acceptance tests, you'll need Vagrant installed.
See LICENSE file.
2015-03-09 Release 1.0.1
- Add groups to the Gemfile
- Remove rspec-system-puppet in favor of the puppetlabs supported beaker
- Adds guard support as well as puppet blacksmith
- Adds boilerplate contrib files.
- Rakefile changes, most notably including puppet-syntax in test task
- metadata.json validation
- Updates to .gitignore
- travis-ci updates, adds future parser testing on 3.7, ruby 2.1 matrix tests
- Pin rspec-puppet to eletrical's fork until pr is merged
- Tell PuppetSyntax not to fail on deprecation notices
- Support the future parse in tests
2015-03-05 Release 1.0.0
- Drop support for ruby 1.8.7
- Add support for ruby 2.0.0
- Bump puppetlabs/apt, puppetlabs/stdlib deps
2015-02-24 Release 0.0.5
- Dont pin puppetlabs/apt at 1.4.0
- Add tests for puppet 3.7
- Add metadata.json, remove Modulefile
2014-09-17 Release 0.0.4
- Add support for changing logdirs
- Add support for changing ncsa log format
2014-06-08 Release 0.0.3
- Add support for puppet 3.6.x
2013-12-11 Release 0.0.2
- Add parameters to configure saintmode and grace times
- Add lb_method and health_check_request support
- Add some hit/miss logging through std.log
- Fix bugs between ruby 1.8 and 1.9
- Update class parameters, confine to init class
- Add support for parameter overrides
2013-11-26 Release 0.0.1
- Initial release of puppet-varnish module
Dependencies
- puppetlabs/stdlib (>=4.0.0)
- puppetlabs/apt (>=1.7.0 <2.0.0)
The MIT License (MIT) Copyright (c) 2013 chartbeat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.