Puppet Class: varnish
- Defined in:
- manifests/init.pp
Overview
Class: varnish
Configure Varnish proxy cache
Parameters
- addrepo
-
Whether to add the official Varnish repos
- secret
-
Varnish secret (used by varnishadm etc). Optional; will be autogenerated if not specified
- vcl_conf
-
Location of Varnish config file template
- listen
-
IP address for HTTP to listen on
- listen_port
-
Port to listen on for HTTP requests
- admin_listen
-
IP address for admin requests - defaults to 127.0.0.1
- admin_port
-
Port for Varnish admin to listen on
- min_threads
-
Varnish minimum thread pool size
- max_threads
-
Varnish maximum thread pool size
- thread_timeout
-
Thread timeout
- storage_type
-
Whether to use malloc (RAM only) or file storage for cache
- storage_size
-
Size of cache
- storage_additional
-
Hash of additional storage backends containing strings in the varnish format (passed to -s)
- varnish_version
-
Major Varnish version to use
- vcl_reload
-
Script to use to load new Varnish config
- package_ensure
-
Ensure specific package version for Varnish, eg 3.0.5-1.el6
- runtime_params
-
Hash of key:value runtime parameters
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'manifests/init.pp', line 43
class varnish (
Hash $runtime_params = {},
Boolean $addrepo = true,
String $admin_listen = '127.0.0.1',
Integer $admin_port = 6082,
Variant[String,Array] $listen = '0.0.0.0',
Integer $listen_port = 6081,
Optional[String] $secret = undef,
Stdlib::AbsolutePath $secret_file = '/etc/varnish/secret',
Stdlib::AbsolutePath $vcl_conf = '/etc/varnish/default.vcl',
Enum['file','malloc'] $storage_type = 'file',
Stdlib::AbsolutePath $storage_file = '/var/lib/varnish/varnish_storage.bin',
String $storage_size = '1G',
Array $storage_additional = [],
Integer $min_threads = 50,
Integer $max_threads = 1000,
Integer $thread_timeout = 120,
Pattern[/^[3-6]\.[0-9](lts)?/] $varnish_version = '4.1',
Optional[String] $instance_name = undef,
String $package_ensure = 'present',
String $package_name = 'varnish',
String $service_name = 'varnish',
Optional[String] $vcl_reload_cmd = undef,
String $vcl_reload_path = $::path,
) {
if $package_ensure == 'present' {
$version_major = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\1')
$version_minor = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\2')
$version_full = $varnish_version
} else {
$version_major = regsubst($package_ensure, '^(\d+)\.(\d+).*$', '\1')
$version_minor = regsubst($package_ensure, '^(\d+)\.(\d+).*$', '\2')
$version_full = "${version_major}.${version_minor}"
if $varnish_version != "${version_major}.${version_minor}" {
fail("Version mismatch, varnish_version is ${varnish_version}, but package_ensure is ${version_full}")
}
}
$version_lts = $varnish_version ? {
/lts$/ => 'lts',
default => '',
}
include ::varnish::params
if $vcl_reload_cmd == undef {
$vcl_reload = $::varnish::params::vcl_reload
} else {
$vcl_reload = $vcl_reload_cmd
}
if $addrepo {
class { '::varnish::repo':
before => Class['::varnish::install'],
}
}
include ::varnish::install
class { '::varnish::secret':
secret => $secret,
require => Class['::varnish::install'],
}
class { '::varnish::config':
require => Class['::varnish::secret'],
notify => Class['::varnish::service'],
}
class { '::varnish::service':
require => Class['::varnish::config'],
}
}
|