Madhuvishy has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337769 )
Change subject: diamond: Allow providing puppet file reference to collector config file ...................................................................... diamond: Allow providing puppet file reference to collector config file The collector.conf.erb that writes collector config files is super limited and doesn't allow for sections and subsections that are supported by the ConfigObject file format - (http://configobj.readthedocs.io/en/latest/configobj.html#the-config-file-format) Expanding the template to support the full feature set seems overly complicated, and the other choices are allowing providing a config file directly, and using a python script that uses the configobj library to write the config file, instead of using puppet templating. The latter is somewhat more complex and can still be done, but at the moment there's no reason to not support writing config files directly - hence this patch. Change-Id: Iacb715ceefa244f4371b71cc350114f1b2fff038 --- M modules/diamond/manifests/collector.pp 1 file changed, 24 insertions(+), 1 deletion(-) Approvals: Madhuvishy: Verified; Looks good to me, approved diff --git a/modules/diamond/manifests/collector.pp b/modules/diamond/manifests/collector.pp index 05fb62e..5e13efc 100644 --- a/modules/diamond/manifests/collector.pp +++ b/modules/diamond/manifests/collector.pp @@ -21,6 +21,13 @@ # A hash of configuration settings for the collector. # The 'enabled' setting is set to true by default. # +# [*config_file*] +# Optional to the settings param, provide a puppet file reference to a +# ConfigObj style config file (configobj is the config file parser used by diamond - +# http://configobj.readthedocs.io/en/latest/configobj.html#the-config-file-format) +# that can be used directly as the collector's config file. +# This makes no assumptions about the 'enabled' setting. +# # [*source*] # A Puppet file reference to the Python collector source file. This parameter # may be omitted if the collector is part of the Diamond distribution. It @@ -56,8 +63,14 @@ # }, # } # +# Configure a custom collector: +# diamond::collector{ 'Custom': +# source => 'puppet:///modules/example/custom_collector.py', +# config_file => 'puppet:///modules/example/CustomCollector.conf'. +# } define diamond::collector( $settings = undef, + $config_file = undef, $ensure = present, $source = undef, $content = undef, @@ -70,11 +83,21 @@ file { "/etc/diamond/collectors/${collector}.conf": ensure => $ensure, - content => template('diamond/collector.conf.erb'), require => File['/etc/diamond/collectors'], notify => Service['diamond'], } + if $config_file != undef { + File["/etc/diamond/collectors/${collector}.conf"] { + source => $config_file, + } + } + else { + File["/etc/diamond/collectors/${collector}.conf"] { + content => template('diamond/collector.conf.erb') + } + } + # Install a custom diamond collector if $source or $content were provided. if $source or $content { file { "/usr/share/diamond/collectors/${name}": -- To view, visit https://gerrit.wikimedia.org/r/337769 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iacb715ceefa244f4371b71cc350114f1b2fff038 Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Madhuvishy <[email protected]> Gerrit-Reviewer: Chasemp <[email protected]> Gerrit-Reviewer: Madhuvishy <[email protected]> Gerrit-Reviewer: Rush <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
