sallinen varnish
[mirror/dsa-puppet.git] / modules / varnish / manifests / config.pp
1 define varnish::config (
2         $listen = ':6081',
3         $source=undef,
4         $content=undef,
5         $ensure = 'present',
6         $backend = "-s malloc,256m",
7 ) {
8         if $name != "default" {
9                 fail ( "This module cannot setup non-default varnish instances yet." )
10         }
11
12         case $ensure {
13                 present: {
14                         include varnish::base
15
16                         if ! ($source or $content) {
17                                 fail ( "No configuration found for ${name}" )
18                         }
19
20                         systemd::override { 'varnish':
21                                 content  => @("EOF"),
22                                         [Service]
23                                         ExecStart=
24                                         ExecStart=/usr/sbin/varnishd -a ${listen} -T localhost:6082 -f /etc/varnish/${name}.vcl -S /etc/varnish/secret -s ${backend}
25                                         | EOF
26                         }
27
28                         $dest = "/etc/varnish/${name}.vcl"
29                         if $content {
30                                 file { "${dest}":
31                                         ensure  => $ensure,
32                                         content => $content,
33                                         notify  => Service["varnish"],
34                                 }
35                         } elsif $source {
36                                 file { "${dest}":
37                                         ensure  => $ensure,
38                                         source  => $source,
39                                         notify  => Service["varnish"],
40                                         }
41                         }
42                 }
43                 default: {
44                         fail ( "Can only deal with ensure=>present for now" )
45                 }
46         }
47 }