sallinen varnish
[mirror/dsa-puppet.git] / modules / varnish / manifests / config.pp
diff --git a/modules/varnish/manifests/config.pp b/modules/varnish/manifests/config.pp
new file mode 100644 (file)
index 0000000..a46f799
--- /dev/null
@@ -0,0 +1,47 @@
+define varnish::config (
+       $listen = ':6081',
+       $source=undef,
+       $content=undef,
+       $ensure = 'present',
+       $backend = "-s malloc,256m",
+) {
+       if $name != "default" {
+               fail ( "This module cannot setup non-default varnish instances yet." )
+       }
+
+       case $ensure {
+               present: {
+                       include varnish::base
+
+                       if ! ($source or $content) {
+                               fail ( "No configuration found for ${name}" )
+                       }
+
+                       systemd::override { 'varnish':
+                               content  => @("EOF"),
+                                       [Service]
+                                       ExecStart=
+                                       ExecStart=/usr/sbin/varnishd -a ${listen} -T localhost:6082 -f /etc/varnish/${name}.vcl -S /etc/varnish/secret -s ${backend}
+                                       | EOF
+                       }
+
+                       $dest = "/etc/varnish/${name}.vcl"
+                       if $content {
+                               file { "${dest}":
+                                       ensure  => $ensure,
+                                       content => $content,
+                                       notify  => Service["varnish"],
+                               }
+                       } elsif $source {
+                               file { "${dest}":
+                                       ensure  => $ensure,
+                                       source  => $source,
+                                       notify  => Service["varnish"],
+                                       }
+                       }
+               }
+               default: {
+                       fail ( "Can only deal with ensure=>present for now" )
+               }
+       }
+}