Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added storage_additional parameter. #52

Merged
merged 1 commit into from Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -103,6 +103,19 @@ To configure Varnish to listen on port 80, specifically on localhost and
}
```

To use multiple storage backends in varnish for example a primary `4GB memory backend` and a `50GB file backend`:

```puppet
class { '::varnish':
storage_type => 'malloc',
storage_size => '4G',
storage_additional => [
'file,/var/lib/varnish/varnish_additional.bin,50G',

]
}
```

### Parameter Reference

|Parameter|Description|
Expand All @@ -122,6 +135,7 @@ To configure Varnish to listen on port 80, specifically on localhost and
|storage_type|malloc or file|
|storage_file|File to mmap on disk for cache storage|
|storage_size|Size of storage file or RAM, eg 10G or 50%|
|storage_additional|Hash of additional storage backends, passed plainly to varnishd -s after the normal configured storage backends|
|package_ensure|Version of Varnish package to install, eg 3.0.5-1.el6|
|runtime_params|hash of run-time parameters to be specified at startup|

Expand Down
47 changes: 25 additions & 22 deletions manifests/init.pp
Expand Up @@ -29,6 +29,8 @@
# 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*]
Expand All @@ -39,28 +41,29 @@
# Hash of key:value runtime parameters
#
class varnish (
$runtime_params = {},
$addrepo = true,
$admin_listen = '127.0.0.1',
$admin_port = '6082',
$listen = '0.0.0.0',
$listen_port = '6081',
$secret = undef,
$secret_file = '/etc/varnish/secret',
$vcl_conf = '/etc/varnish/default.vcl',
$storage_type = 'file',
$storage_file = '/var/lib/varnish/varnish_storage.bin',
$storage_size = '1G',
$min_threads = '50',
$max_threads = '1000',
$thread_timeout = '120',
$varnish_version = '4.1',
$instance_name = undef,
$package_ensure = 'present',
$package_name = 'varnish',
$service_name = 'varnish',
$vcl_reload_cmd = undef,
$vcl_reload_path = $::path,
$runtime_params = {},
$addrepo = true,
$admin_listen = '127.0.0.1',
$admin_port = '6082',
$listen = '0.0.0.0',
$listen_port = '6081',
$secret = undef,
$secret_file = '/etc/varnish/secret',
$vcl_conf = '/etc/varnish/default.vcl',
$storage_type = 'file',
$storage_file = '/var/lib/varnish/varnish_storage.bin',
$storage_size = '1G',
$storage_additional = [],
$min_threads = '50',
$max_threads = '1000',
$thread_timeout = '120',
$varnish_version = '4.1',
$instance_name = undef,
$package_ensure = 'present',
$package_name = 'varnish',
$service_name = 'varnish',
$vcl_reload_cmd = undef,
$vcl_reload_path = $::path,
) {

if $package_ensure == 'present' {
Expand Down
5 changes: 4 additions & 1 deletion templates/sysconfig.erb
Expand Up @@ -50,4 +50,7 @@ DAEMON_OPTS="<% if scope['::varnish::params::service_provider'] == 'sysvinit' -%
-p <%= k %>=<%= v %> \
<% end -%>
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"
-s ${VARNISH_STORAGE} \
<% scope['::varnish::storage_additional'].each do |k| -%>
-s <%= k %> \
<% end -%>"
5 changes: 4 additions & 1 deletion templates/varnish.service.erb
Expand Up @@ -41,7 +41,10 @@ ExecStart=/usr/sbin/varnishd <%= scope['::varnish::config::jail_opt'] %> \
-p <%= k %>=<%= v %> \
<% end -%>
-S <%= scope['::varnish::secret_file'] %> \
-s <%= scope['::varnish::storage_type'] %>,<% if scope['::varnish::storage_type'] == 'file' -%><%= scope['::varnish::storage_file'] %>,<% end -%><%= scope['::varnish::storage_size'] %>
-s <%= scope['::varnish::storage_type'] %>,<% if scope['::varnish::storage_type'] == 'file' -%><%= scope['::varnish::storage_file'] %>,<% end -%><%= scope['::varnish::storage_size'] %> \
<% scope['::varnish::storage_additional'].each do |k| -%>
-s <%= k %> \
<% end -%>

[Install]
WantedBy=multi-user.target