Mark Bergsma has submitted this change and it was merged.

Change subject: Move manifests/varnish.pp to a module
......................................................................


Move manifests/varnish.pp to a module

Change-Id: I12f9956c9a16829b4bcf53820c5df110dc81fbb5
---
M manifests/site.pp
D manifests/varnish.pp
A modules/varnish/files/ganglia/.pep8
R modules/varnish/files/ganglia/ganglia-varnish.py
R modules/varnish/files/reload-vcl
R modules/varnish/files/varnishncsa.default
A modules/varnish/htcppurger.pp
A modules/varnish/manifests/common.pp
A modules/varnish/manifests/common/vcl.pp
A modules/varnish/manifests/extra_vcl.pp
A modules/varnish/manifests/init.pp
A modules/varnish/manifests/instance.pp
A modules/varnish/manifests/logging.pp
A modules/varnish/manifests/logging/config.pp
A modules/varnish/manifests/logging/monitor.pp
A modules/varnish/manifests/monitoring/ganglia.pp
A modules/varnish/manifests/packages.pp
A modules/varnish/manifests/setup_filesystem.pp
R modules/varnish/templates/varnish-default.erb
R modules/varnish/templates/varnish.init.erb
R modules/varnish/templates/varnishncsa.init.erb
R modules/varnish/templates/vcl/wikimedia.vcl.erb
22 files changed, 275 insertions(+), 284 deletions(-)

Approvals:
  Mark Bergsma: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/manifests/site.pp b/manifests/site.pp
index 144e38d..7c46aa4 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -37,7 +37,6 @@
 import "squid.pp"
 import "svn.pp"
 import "swift.pp"
-import "varnish.pp"
 import "webserver.pp"
 import "zuul.pp"
 
diff --git a/manifests/varnish.pp b/manifests/varnish.pp
deleted file mode 100644
index ff34fef..0000000
--- a/manifests/varnish.pp
+++ /dev/null
@@ -1,283 +0,0 @@
-# varnish.pp
-
-class varnish::packages($version="installed") {
-    package { [ 'varnish', 'libvarnishapi1', 'varnish-dbg' ]:
-        ensure => $version;
-    }
-}
-
-class varnish::common {
-    require varnish::packages
-
-    # Tune kernel settings
-    include generic::sysctl::high-http-performance
-
-    # Mount /var/lib/ganglia as tmpfs to avoid Linux flushing mlocked
-    # shm memory to disk
-    mount { "/var/lib/varnish":
-        require => Class["varnish::packages"],
-        device => "tmpfs",
-        fstype => "tmpfs",
-        options => "noatime,defaults,size=512M",
-        pass => 0,
-        dump => 0,
-        ensure => mounted;
-    }
-
-    file {
-        "/usr/share/varnish/reload-vcl":
-            source => "puppet:///files/varnish/reload-vcl",
-            mode => 0555;
-    }
-}
-
-class varnish::common::vcl {
-    require "varnish::common"
-
-    file {
-        "/etc/varnish/geoip.inc.vcl":
-            content => template("varnish/geoip.inc.vcl.erb");
-        "/etc/varnish/device-detection.inc.vcl":
-            content => template("varnish/device-detection.inc.vcl.erb");
-        "/etc/varnish/errorpage.inc.vcl":
-            content => template("varnish/errorpage.inc.vcl.erb");
-    }
-}
-
-define varnish::extra_vcl {
-    $vcl = regsubst($title, '^([^ ]+) .*$', '\1')
-    $filename = "/etc/varnish/${vcl}.inc.vcl"
-    if !defined(File[$filename]) {
-        file { $filename:
-            content => template("varnish/${vcl}.inc.vcl.erb"),
-            mode => 0444;
-        }
-    }
-}
-
-define varnish::instance(
-    $name="",
-    $vcl = "",
-    $extra_vcl = [],
-    $port="80",
-    $admin_port="6083",
-    $storage="-s malloc,1G",
-    $runtime_parameters=[],
-    $backends=undef,
-    $directors={},
-    $director_type="hash",
-    $director_options={},
-    $vcl_config,
-    $backend_options,
-    $cluster_options={},
-    $wikimedia_networks=[],
-    $xff_sources=[]) {
-
-    include varnish::common
-
-    $runtime_params = join(prefix($runtime_parameters, "-p "), " ")
-    if $name == "" {
-        $instancesuffix = ""
-        $extraopts = ""
-    }
-    else {
-        $instancesuffix = "-${name}"
-        $extraopts = "-n ${name}"
-    }
-
-    # Initialize variables for templates
-    # FIXME: get rid of the $varnish_* below and update the templates
-    $varnish_port = $port
-    $varnish_admin_port = $admin_port
-    $varnish_storage = $storage
-    $varnish_backends = $backends ? { undef => 
sort(unique(flatten(values($directors)))), default => $backends }
-    $varnish_directors = $directors
-    $varnish_backend_options = $backend_options
-    # $cluster_option is referenced directly
-
-    # Install VCL include files shared by all instances
-    require "varnish::common::vcl"
-
-    $extra_vcl_variable_to_make_puppet_parser_happy = suffix($extra_vcl, " 
${instancesuffix}")
-    extra_vcl{ $extra_vcl_variable_to_make_puppet_parser_happy: }
-
-    file {
-        "/etc/init.d/varnish${instancesuffix}":
-            content => template("varnish/varnish.init.erb"),
-            mode => 0555;
-        "/etc/default/varnish${instancesuffix}":
-            content => template("varnish/varnish-default.erb"),
-            mode => 0444;
-        "/etc/varnish/${vcl}.inc.vcl":
-            content => template("varnish/${vcl}.inc.vcl.erb"),
-            notify => Exec["load-new-vcl-file${instancesuffix}"],
-            mode => 0444;
-        "/etc/varnish/wikimedia_${vcl}.vcl":
-            require => File["/etc/varnish/${vcl}.inc.vcl"],
-            content => template("varnish/wikimedia.vcl.erb"),
-            mode => 0444;
-    }
-
-    service { "varnish${instancesuffix}":
-        require => [
-                File[
-                    "/etc/default/varnish${instancesuffix}",
-                    "/etc/init.d/varnish${instancesuffix}",
-                    "/etc/varnish/${vcl}.inc.vcl",
-                    "/etc/varnish/wikimedia_${vcl}.vcl"
-                ],
-                Mount["/var/lib/varnish"]
-            ],
-        hasstatus => false,
-        pattern => "/var/run/varnishd${instancesuffix}.pid",
-        subscribe => Package[varnish],
-        ensure => running;
-    }
-
-    exec { "load-new-vcl-file${instancesuffix}":
-        require => [ Service["varnish${instancesuffix}"], 
File["/etc/varnish/wikimedia_${vcl}.vcl"] ],
-        subscribe => [File["/etc/varnish/wikimedia_${vcl}.vcl"],
-            Class["varnish::common::vcl"],
-            File[suffix(prefix($extra_vcl, "/etc/varnish/"), ".inc.vcl")]
-            ],
-        command => "/usr/share/varnish/reload-vcl $extraopts",
-        path => "/bin:/usr/bin",
-        refreshonly => true;
-    }
-
-    monitor_service { "varnish http ${title}":
-        description => "Varnish HTTP ${title}",
-        check_command => "check_http_generic!varnishcheck!${port}"
-    }
-
-    # Restart gmond if this varnish instance has been (re)started later
-    # than gmond was started
-    exec { "restart gmond for varnish${instancesuffix}":
-        path => "/bin:/sbin:/usr/bin:/usr/sbin",
-        command => "true",
-        onlyif => "test /var/run/varnishd${instancesuffix}.pid -nt 
/var/run/gmond.pid",
-        notify => Service[gmond]
-    }
-}
-
-class varnish::monitoring::ganglia($varnish_instances=['']) {
-    $instances = join($varnish_instances, ",")
-
-    file { "/usr/lib/ganglia/python_modules/varnish.py":
-        require => File["/usr/lib/ganglia/python_modules"],
-        source => "puppet:///files/ganglia/plugins/varnish.py";
-    }
-
-    exec {
-        "generate varnish.pyconf":
-            require => File["/usr/lib/ganglia/python_modules/varnish.py", 
"/etc/ganglia/conf.d"],
-            command => "/usr/bin/python 
/usr/lib/ganglia/python_modules/varnish.py \"$instances\" > 
/etc/ganglia/conf.d/varnish.pyconf.new";
-        "replace varnish.pyconf":
-            cwd => "/etc/ganglia/conf.d",
-            path => "/bin:/usr/bin",
-            unless => "diff -q varnish.pyconf.new varnish.pyconf && rm 
varnish.pyconf.new",
-            command => "mv varnish.pyconf.new varnish.pyconf",
-            notify => Service[gmond];
-    }
-    Exec["generate varnish.pyconf"] -> Exec["replace varnish.pyconf"]
-}
-
-define varnish::setup_filesystem() {
-    file { "/srv/${title}":
-        owner => root,
-        group => root,
-        ensure => directory
-    }
-
-    mount { "/srv/${title}":
-        require => File["/srv/${title}"],
-        device => "/dev/${title}",
-        fstype => "auto",
-        options => $::realm ? {
-            'production' => "noatime,nodiratime,nobarrier,logbufs=8",
-            'labs' => "noatime,nodiratime,nobarrier,comment=cloudconfig"
-        },
-        ensure => mounted
-    }
-}
-
-class varnish::htcppurger($varnish_instances=["localhost:80"]) {
-    Class[varnish::packages] -> Class[varnish::htcppurger]
-
-    package { "vhtcpd":
-        ensure => latest,
-    }
-
-    file { "/etc/default/vhtcpd":
-        owner => root,
-        group => root,
-        mode => 0444,
-        require => Package["vhtcpd"], # if we go first, we get overwritten
-        # TODO: -r ^upload\\.wikimedia\\.org\$ (POSIX ERE, new param for 
class, quoting/escaping will be tricky...)
-        # TODO: remove -F when VCL updated to match (no hostname in PURGE URL)
-        content => inline_template('DAEMON_OPTS="-F -m 239.128.0.112<% 
varnish_instances.each do |inst| -%> -c <%= inst %><% end -%>"');
-    }
-
-    service { vhtcpd:
-        require => Package["vhtcpd"],
-        subscribe => File["/etc/default/vhtcpd"],
-        hasstatus => true,
-        hasrestart => true,
-        ensure => running;
-    }
-
-    nrpe::monitor_service { "vhtcpd":
-        description => "Varnish HTCP daemon",
-        nrpe_command => "/usr/lib/nagios/plugins/check_procs -c 1:1 -u vhtcpd 
-a vhtcpd"
-    }
-}
-
-class varnish::logging::config {
-    file { "/etc/default/varnishncsa":
-        source => "puppet:///files/varnish/varnishncsa.default",
-        owner => root,
-        group => root,
-        mode => 0444;
-    }
-}
-
-class varnish::logging::monitor {
-    nrpe::monitor_service { "varnishncsa":
-        description => "Varnish traffic logger",
-        nrpe_command => "/usr/lib/nagios/plugins/check_procs -w 2:2 -c 2:4 -C 
varnishncsa"
-    }
-}
-
-define varnish::logging($listener_address, $port="8420", $cli_args="", 
$log_fmt=false, $instance_name="frontend", $monitor=true) {
-    require varnish::packages,
-        varnish::logging::config
-    if $monitor {
-        require varnish::logging::monitor
-    }
-
-    $varnishservice = $instance_name ? {
-        "" => "varnish",
-        default => "varnish-${instance_name}"
-    }
-
-    $shm_name = $instance_name ? {
-        "" => $hostname,
-        default => $instance_name
-    }
-
-    file { "/etc/init.d/varnishncsa-${name}":
-        content => template("varnish/varnishncsa.init.erb"),
-        owner => root,
-        group => root,
-        mode => 0555,
-        notify => Service["varnishncsa-${name}"];
-    }
-
-    service { "varnishncsa-${name}":
-        require => [ File["/etc/init.d/varnishncsa-${name}"], 
Service[$varnishservice] ],
-        subscribe => File["/etc/default/varnishncsa"],
-        ensure => running,
-        pattern => "/var/run/varnishncsa/varnishncsa-${name}.pid",
-        hasstatus => false;
-    }
-}
diff --git a/modules/varnish/files/ganglia/.pep8 
b/modules/varnish/files/ganglia/.pep8
new file mode 100644
index 0000000..2f6357a
--- /dev/null
+++ b/modules/varnish/files/ganglia/.pep8
@@ -0,0 +1,2 @@
+[pep8]
+exclude=*
diff --git a/files/ganglia/plugins/varnish.py 
b/modules/varnish/files/ganglia/ganglia-varnish.py
similarity index 100%
rename from files/ganglia/plugins/varnish.py
rename to modules/varnish/files/ganglia/ganglia-varnish.py
diff --git a/files/varnish/reload-vcl b/modules/varnish/files/reload-vcl
similarity index 100%
rename from files/varnish/reload-vcl
rename to modules/varnish/files/reload-vcl
diff --git a/files/varnish/varnishncsa.default 
b/modules/varnish/files/varnishncsa.default
similarity index 100%
rename from files/varnish/varnishncsa.default
rename to modules/varnish/files/varnishncsa.default
diff --git a/modules/varnish/htcppurger.pp b/modules/varnish/htcppurger.pp
new file mode 100644
index 0000000..fb877c4
--- /dev/null
+++ b/modules/varnish/htcppurger.pp
@@ -0,0 +1,30 @@
+class varnish::htcppurger($varnish_instances=["localhost:80"]) {
+    Class[varnish::packages] -> Class[varnish::htcppurger]
+
+    package { "vhtcpd":
+        ensure => latest,
+    }
+
+    file { "/etc/default/vhtcpd":
+        owner => root,
+        group => root,
+        mode => 0444,
+        require => Package["vhtcpd"], # if we go first, we get overwritten
+        # TODO: -r ^upload\\.wikimedia\\.org\$ (POSIX ERE, new param for 
class, quoting/escaping will be tricky...)
+        # TODO: remove -F when VCL updated to match (no hostname in PURGE URL)
+        content => inline_template('DAEMON_OPTS="-F -m 239.128.0.112<% 
varnish_instances.each do |inst| -%> -c <%= inst %><% end -%>"');
+    }
+
+    service { vhtcpd:
+        require => Package["vhtcpd"],
+        subscribe => File["/etc/default/vhtcpd"],
+        hasstatus => true,
+        hasrestart => true,
+        ensure => running;
+    }
+
+    nrpe::monitor_service { "vhtcpd":
+        description => "Varnish HTCP daemon",
+        nrpe_command => "/usr/lib/nagios/plugins/check_procs -c 1:1 -u vhtcpd 
-a vhtcpd"
+    }
+}
diff --git a/modules/varnish/manifests/common.pp 
b/modules/varnish/manifests/common.pp
new file mode 100644
index 0000000..045a5db
--- /dev/null
+++ b/modules/varnish/manifests/common.pp
@@ -0,0 +1,24 @@
+class varnish::common {
+    require varnish::packages
+
+    # Tune kernel settings
+    include generic::sysctl::high-http-performance
+
+    # Mount /var/lib/ganglia as tmpfs to avoid Linux flushing mlocked
+    # shm memory to disk
+    mount { "/var/lib/varnish":
+        require => Class["varnish::packages"],
+        device => "tmpfs",
+        fstype => "tmpfs",
+        options => "noatime,defaults,size=512M",
+        pass => 0,
+        dump => 0,
+        ensure => mounted;
+    }
+
+    file {
+        "/usr/share/varnish/reload-vcl":
+            source => "puppet:///modules/${module_name}/reload-vcl",
+            mode => 0555;
+    }
+}
diff --git a/modules/varnish/manifests/common/vcl.pp 
b/modules/varnish/manifests/common/vcl.pp
new file mode 100644
index 0000000..877b178
--- /dev/null
+++ b/modules/varnish/manifests/common/vcl.pp
@@ -0,0 +1,12 @@
+class varnish::common::vcl {
+    require "varnish::common"
+
+    file {
+        "/etc/varnish/geoip.inc.vcl":
+            content => template("varnish/geoip.inc.vcl.erb");
+        "/etc/varnish/device-detection.inc.vcl":
+            content => template("varnish/device-detection.inc.vcl.erb");
+        "/etc/varnish/errorpage.inc.vcl":
+            content => template("varnish/errorpage.inc.vcl.erb");
+    }
+}
diff --git a/modules/varnish/manifests/extra_vcl.pp 
b/modules/varnish/manifests/extra_vcl.pp
new file mode 100644
index 0000000..fe65d94
--- /dev/null
+++ b/modules/varnish/manifests/extra_vcl.pp
@@ -0,0 +1,10 @@
+define varnish::extra_vcl {
+    $vcl = regsubst($title, '^([^ ]+) .*$', '\1')
+    $filename = "/etc/varnish/${vcl}.inc.vcl"
+    if !defined(File[$filename]) {
+        file { $filename:
+            content => template("varnish/${vcl}.inc.vcl.erb"),
+            mode => 0444;
+        }
+    }
+}
diff --git a/modules/varnish/manifests/init.pp 
b/modules/varnish/manifests/init.pp
new file mode 100644
index 0000000..1bb0ba1
--- /dev/null
+++ b/modules/varnish/manifests/init.pp
@@ -0,0 +1,2 @@
+class varnish {
+}
\ No newline at end of file
diff --git a/modules/varnish/manifests/instance.pp 
b/modules/varnish/manifests/instance.pp
new file mode 100644
index 0000000..e1baf01
--- /dev/null
+++ b/modules/varnish/manifests/instance.pp
@@ -0,0 +1,104 @@
+define varnish::instance(
+    $name="",
+    $vcl = "",
+    $extra_vcl = [],
+    $port="80",
+    $admin_port="6083",
+    $storage="-s malloc,1G",
+    $runtime_parameters=[],
+    $backends=undef,
+    $directors={},
+    $director_type="hash",
+    $director_options={},
+    $vcl_config,
+    $backend_options,
+    $cluster_options={},
+    $wikimedia_networks=[],
+    $xff_sources=[]) {
+
+    include varnish::common
+
+    $runtime_params = join(prefix($runtime_parameters, "-p "), " ")
+    if $name == "" {
+        $instancesuffix = ""
+        $extraopts = ""
+    }
+    else {
+        $instancesuffix = "-${name}"
+        $extraopts = "-n ${name}"
+    }
+
+    # Initialize variables for templates
+    # FIXME: get rid of the $varnish_* below and update the templates
+    $varnish_port = $port
+    $varnish_admin_port = $admin_port
+    $varnish_storage = $storage
+    $varnish_backends = $backends ? { undef => 
sort(unique(flatten(values($directors)))), default => $backends }
+    $varnish_directors = $directors
+    $varnish_backend_options = $backend_options
+    # $cluster_option is referenced directly
+
+    # Install VCL include files shared by all instances
+    require "varnish::common::vcl"
+
+    $extra_vcl_variable_to_make_puppet_parser_happy = suffix($extra_vcl, " 
${instancesuffix}")
+    extra_vcl{ $extra_vcl_variable_to_make_puppet_parser_happy: }
+
+    file {
+        "/etc/init.d/varnish${instancesuffix}":
+            content => template("${module_name}/varnish.init.erb"),
+            mode => 0555;
+        "/etc/default/varnish${instancesuffix}":
+            content => template("${module_name}/varnish-default.erb"),
+            mode => 0444;
+        "/etc/varnish/${vcl}.inc.vcl":
+            content => template("varnish/${vcl}.inc.vcl.erb"),
+            notify => Exec["load-new-vcl-file${instancesuffix}"],
+            mode => 0444;
+        "/etc/varnish/wikimedia_${vcl}.vcl":
+            require => File["/etc/varnish/${vcl}.inc.vcl"],
+            content => template("${module_name}/vcl/wikimedia.vcl.erb"),
+            mode => 0444;
+    }
+
+    service { "varnish${instancesuffix}":
+        require => [
+                File[
+                    "/etc/default/varnish${instancesuffix}",
+                    "/etc/init.d/varnish${instancesuffix}",
+                    "/etc/varnish/${vcl}.inc.vcl",
+                    "/etc/varnish/wikimedia_${vcl}.vcl"
+                ],
+                Mount["/var/lib/varnish"]
+            ],
+        hasstatus => false,
+        pattern => "/var/run/varnishd${instancesuffix}.pid",
+        subscribe => Package[varnish],
+        ensure => running;
+    }
+
+    exec { "load-new-vcl-file${instancesuffix}":
+        require => [ Service["varnish${instancesuffix}"], 
File["/etc/varnish/wikimedia_${vcl}.vcl"] ],
+        subscribe => [File["/etc/varnish/wikimedia_${vcl}.vcl"],
+            Class["varnish::common::vcl"],
+            File[suffix(prefix($extra_vcl, "/etc/varnish/"), ".inc.vcl")]
+            ],
+        command => "/usr/share/varnish/reload-vcl $extraopts",
+        path => "/bin:/usr/bin",
+        refreshonly => true;
+    }
+
+    monitor_service { "varnish http ${title}":
+        description => "Varnish HTTP ${title}",
+        check_command => "check_http_generic!varnishcheck!${port}"
+    }
+
+    # Restart gmond if this varnish instance has been (re)started later
+    # than gmond was started
+    exec { "restart gmond for varnish${instancesuffix}":
+        path => "/bin:/sbin:/usr/bin:/usr/sbin",
+        command => "true",
+        onlyif => "test /var/run/varnishd${instancesuffix}.pid -nt 
/var/run/gmond.pid",
+        notify => Service[gmond]
+    }
+}
\ No newline at end of file
diff --git a/modules/varnish/manifests/logging.pp 
b/modules/varnish/manifests/logging.pp
new file mode 100644
index 0000000..2272c36
--- /dev/null
+++ b/modules/varnish/manifests/logging.pp
@@ -0,0 +1,33 @@
+define varnish::logging($listener_address, $port="8420", $cli_args="", 
$log_fmt=false, $instance_name="frontend", $monitor=true) {
+    require varnish::packages,
+        varnish::logging::config
+    if $monitor {
+        require varnish::logging::monitor
+    }
+
+    $varnishservice = $instance_name ? {
+        "" => "varnish",
+        default => "varnish-${instance_name}"
+    }
+
+    $shm_name = $instance_name ? {
+        "" => $hostname,
+        default => $instance_name
+    }
+
+    file { "/etc/init.d/varnishncsa-${name}":
+        content => template("${module_name}/varnishncsa.init.erb"),
+        owner => root,
+        group => root,
+        mode => 0555,
+        notify => Service["varnishncsa-${name}"];
+    }
+
+    service { "varnishncsa-${name}":
+        require => [ File["/etc/init.d/varnishncsa-${name}"], 
Service[$varnishservice] ],
+        subscribe => File["/etc/default/varnishncsa"],
+        ensure => running,
+        pattern => "/var/run/varnishncsa/varnishncsa-${name}.pid",
+        hasstatus => false;
+    }
+}
\ No newline at end of file
diff --git a/modules/varnish/manifests/logging/config.pp 
b/modules/varnish/manifests/logging/config.pp
new file mode 100644
index 0000000..1f8e3ba
--- /dev/null
+++ b/modules/varnish/manifests/logging/config.pp
@@ -0,0 +1,8 @@
+class varnish::logging::config {
+    file { "/etc/default/varnishncsa":
+        source => "puppet:///modules/${module_name}/varnishncsa.default",
+        owner => root,
+        group => root,
+        mode => 0444;
+    }
+}
diff --git a/modules/varnish/manifests/logging/monitor.pp 
b/modules/varnish/manifests/logging/monitor.pp
new file mode 100644
index 0000000..8238862
--- /dev/null
+++ b/modules/varnish/manifests/logging/monitor.pp
@@ -0,0 +1,6 @@
+class varnish::logging::monitor {
+    nrpe::monitor_service { "varnishncsa":
+        description => "Varnish traffic logger",
+        nrpe_command => "/usr/lib/nagios/plugins/check_procs -w 2:2 -c 2:4 -C 
varnishncsa"
+    }
+}
diff --git a/modules/varnish/manifests/monitoring/ganglia.pp 
b/modules/varnish/manifests/monitoring/ganglia.pp
new file mode 100644
index 0000000..58c2b1e
--- /dev/null
+++ b/modules/varnish/manifests/monitoring/ganglia.pp
@@ -0,0 +1,21 @@
+class varnish::monitoring::ganglia($varnish_instances=['']) {
+    $instances = join($varnish_instances, ",")
+
+    file { "/usr/lib/ganglia/python_modules/varnish.py":
+        require => File["/usr/lib/ganglia/python_modules"],
+        source => 
"puppet:///modules/${module_name}/ganglia/ganglia-varnish.py";
+    }
+
+    exec {
+        "generate varnish.pyconf":
+            require => File["/usr/lib/ganglia/python_modules/varnish.py", 
"/etc/ganglia/conf.d"],
+            command => "/usr/bin/python 
/usr/lib/ganglia/python_modules/varnish.py \"$instances\" > 
/etc/ganglia/conf.d/varnish.pyconf.new";
+        "replace varnish.pyconf":
+            cwd => "/etc/ganglia/conf.d",
+            path => "/bin:/usr/bin",
+            unless => "diff -q varnish.pyconf.new varnish.pyconf && rm 
varnish.pyconf.new",
+            command => "mv varnish.pyconf.new varnish.pyconf",
+            notify => Service[gmond];
+    }
+    Exec["generate varnish.pyconf"] -> Exec["replace varnish.pyconf"]
+}
diff --git a/modules/varnish/manifests/packages.pp 
b/modules/varnish/manifests/packages.pp
new file mode 100644
index 0000000..974de47
--- /dev/null
+++ b/modules/varnish/manifests/packages.pp
@@ -0,0 +1,5 @@
+class varnish::packages($version="installed") {
+    package { [ 'varnish', 'libvarnishapi1', 'varnish-dbg' ]:
+        ensure => $version;
+    }
+}
diff --git a/modules/varnish/manifests/setup_filesystem.pp 
b/modules/varnish/manifests/setup_filesystem.pp
new file mode 100644
index 0000000..acb11e2
--- /dev/null
+++ b/modules/varnish/manifests/setup_filesystem.pp
@@ -0,0 +1,18 @@
+define varnish::setup_filesystem() {
+    file { "/srv/${title}":
+        owner => root,
+        group => root,
+        ensure => directory
+    }
+
+    mount { "/srv/${title}":
+        require => File["/srv/${title}"],
+        device => "/dev/${title}",
+        fstype => "auto",
+        options => $::realm ? {
+            'production' => "noatime,nodiratime,nobarrier,logbufs=8",
+            'labs' => "noatime,nodiratime,nobarrier,comment=cloudconfig"
+        },
+        ensure => mounted
+    }
+}
diff --git a/templates/varnish/varnish-default.erb 
b/modules/varnish/templates/varnish-default.erb
similarity index 100%
rename from templates/varnish/varnish-default.erb
rename to modules/varnish/templates/varnish-default.erb
diff --git a/templates/varnish/varnish.init.erb 
b/modules/varnish/templates/varnish.init.erb
similarity index 100%
rename from templates/varnish/varnish.init.erb
rename to modules/varnish/templates/varnish.init.erb
diff --git a/templates/varnish/varnishncsa.init.erb 
b/modules/varnish/templates/varnishncsa.init.erb
similarity index 100%
rename from templates/varnish/varnishncsa.init.erb
rename to modules/varnish/templates/varnishncsa.init.erb
diff --git a/templates/varnish/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
similarity index 100%
rename from templates/varnish/wikimedia.vcl.erb
rename to modules/varnish/templates/vcl/wikimedia.vcl.erb

-- 
To view, visit https://gerrit.wikimedia.org/r/68653
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I12f9956c9a16829b4bcf53820c5df110dc81fbb5
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to