Giuseppe Lavagetto has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/382674 )

Change subject: role::cache::base: abstract varnish logging to class
......................................................................


role::cache::base: abstract varnish logging to class

We were calling several defines for analytics/logging, with multiple
hiera calls (duplicated!). Encapsulate all those declarations to a
class, as it makes sense.

Change-Id: I830c585cfbfd96325ee6f1db410a1c6afc29a9be
---
M modules/role/manifests/cache/base.pp
A modules/varnish/manifests/logging.pp
2 files changed, 40 insertions(+), 21 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  Ema: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/modules/role/manifests/cache/base.pp 
b/modules/role/manifests/cache/base.pp
index 82001df..e595159 100644
--- a/modules/role/manifests/cache/base.pp
+++ b/modules/role/manifests/cache/base.pp
@@ -14,6 +14,7 @@
 
 
     $cache_cluster = hiera('cache::cluster')
+    $statsd_host = hiera('statsd')
 
     system::role { "cache::${cache_cluster}":
         description => "${cache_cluster} Varnish cache server",
@@ -50,33 +51,15 @@
     ###########################################################################
     # Analytics/Logging stuff
     ###########################################################################
-
-    # Client connection stats from the 'X-Connection-Properties'
-    # header set by the SSL terminators.
-    ::varnish::logging::xcps { 'xcps':
-        statsd_server => hiera('statsd'),
-    }
-
-    ::varnish::logging::statsd { 'default':
-        statsd_server => hiera('statsd'),
-        key_prefix    => "varnish.${::site}.backends",
+    class { '::varnish::logging':
+        cache_cluster => $cache_cluster,
+        statsd_host   => $statsd_host,
     }
 
     # Install a varnishkafka producer to send
     # varnish webrequest logs to Kafka.
     class { 'role::cache::kafka::webrequest':
         topic => "webrequest_${cache_cluster}",
-    }
-
-    # Parse varnishlogs for request statistics and send to statsd.
-    varnish::logging::reqstats { 'frontend':
-        key_prefix => "varnish.${::site}.${cache_cluster}.frontend.request",
-        statsd     => hiera('statsd'),
-    }
-
-    ::varnish::logging::xcache { 'xcache':
-        key_prefix    => "varnish.${::site}.${cache_cluster}.xcache",
-        statsd_server => hiera('statsd'),
     }
 
     ###########################################################################
diff --git a/modules/varnish/manifests/logging.pp 
b/modules/varnish/manifests/logging.pp
new file mode 100644
index 0000000..1c2da9a
--- /dev/null
+++ b/modules/varnish/manifests/logging.pp
@@ -0,0 +1,36 @@
+# == Class varnish::logging
+#
+# This class sets up analytics/logging needed by cache servers
+#
+# === Parameters
+#
+# [*cache_cluster*] The cache cluster we're part of.
+#
+# [*statsd_host*] The statsd host to send stats to.
+#
+class varnish::logging(
+    $cache_cluster,
+    $statsd_host,
+){
+    # Client connection stats from the 'X-Connection-Properties'
+    # header set by the SSL terminators.
+    ::varnish::logging::xcps { 'xcps':
+        statsd_server => $statsd_host,
+    }
+
+    ::varnish::logging::statsd { 'default':
+        statsd_server => $statsd_host,
+        key_prefix    => "varnish.${::site}.backends",
+    }
+
+    # Parse varnishlogs for request statistics and send to statsd.
+    varnish::logging::reqstats { 'frontend':
+        key_prefix => "varnish.${::site}.${cache_cluster}.frontend.request",
+        statsd     => $statsd_host,
+    }
+
+    ::varnish::logging::xcache { 'xcache':
+        key_prefix    => "varnish.${::site}.${cache_cluster}.xcache",
+        statsd_server => $statsd_host,
+    }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I830c585cfbfd96325ee6f1db410a1c6afc29a9be
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Ema <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to