Ottomata has submitted this change and it was merged.
Change subject: Add diamond collector_module class
......................................................................
Add diamond collector_module class
This decouples the installation of custom collectors from their
usage via the diamond::collector class.
Bug: T83580
Change-Id: I7b64baa7659f0bbe97309fbf461eded40a6e63df
---
M modules/diamond/manifests/collector.pp
A modules/diamond/manifests/collector_module.pp
2 files changed, 44 insertions(+), 12 deletions(-)
Approvals:
Filippo Giunchedi: Looks good to me, but someone else must approve
Ottomata: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/diamond/manifests/collector.pp
b/modules/diamond/manifests/collector.pp
index 9ec19df..8e8d317 100644
--- a/modules/diamond/manifests/collector.pp
+++ b/modules/diamond/manifests/collector.pp
@@ -65,21 +65,13 @@
notify => Service['diamond'],
}
+ # If this is a custom collector, use the collector_module class
+ # to install the custom python collector.
if $source {
- file { "/usr/share/diamond/collectors/${name}":
- ensure => ensure_directory($ensure),
- owner => 'root',
- group => 'root',
- mode => '0755',
- }
-
- file { "/usr/share/diamond/collectors/${name}/${name}.py":
+ class { '::diamond::collector_module':
ensure => $ensure,
- before => File["/etc/diamond/collectors/${collector}.conf"],
+ name => $name,
source => $source,
- owner => 'root',
- group => 'root',
- mode => '0644',
}
}
}
diff --git a/modules/diamond/manifests/collector_module.pp
b/modules/diamond/manifests/collector_module.pp
new file mode 100644
index 0000000..ef8cdd6
--- /dev/null
+++ b/modules/diamond/manifests/collector_module.pp
@@ -0,0 +1,40 @@
+# == Class diamond::collector_module
+# Installs a python diamond collector module.
+#
+# === Parameters
+# [*ensure*]
+# Specifies whether or not this Diamond python module should exist.
+# The default is 'present'.
+#
+# [*name*]
+# The name of the collector class. The 'Collector' suffix may be
+# omitted from the name.
+#
+# [*source*]
+# A Puppet file reference to the Python collector source file.
+#
+class diamond::collector_module(
+ $ensure = 'present',
+ $name,
+ $source,
+) {
+ include ::diamond
+
+ validate_ensure($ensure)
+
+ file { "/usr/share/diamond/collectors/${name}":
+ ensure => ensure_directory($ensure),
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ }
+
+ file { "/usr/share/diamond/collectors/${name}/${name}.py":
+ ensure => $ensure,
+ before => File["/etc/diamond/collectors/${collector}.conf"],
+ source => $source,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/214053
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7b64baa7659f0bbe97309fbf461eded40a6e63df
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits