Rush has submitted this change and it was merged.

Change subject: confd additions for pybal
......................................................................


confd additions for pybal

* template-ize a passed in string for
  go lang template inside of the defined type
  to get the correct scope variables

* no nrpe::monitor_systemd_unit for precise

This is a companion change to 217973

Change-Id: Ic9367777879dbcebae72ef5c21b28899e9c6344b
---
M modules/confd/manifests/file.pp
M modules/confd/manifests/init.pp
M modules/confd/templates/service_template.toml.erb
3 files changed, 31 insertions(+), 24 deletions(-)

Approvals:
  Rush: Looks good to me, approved
  Giuseppe Lavagetto: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/confd/manifests/file.pp b/modules/confd/manifests/file.pp
index c4ff2d7..f6775a3 100644
--- a/modules/confd/manifests/file.pp
+++ b/modules/confd/manifests/file.pp
@@ -2,24 +2,21 @@
 #
 # Defines a service template to be monitored by confd,
 # and the corresponding geneated config file.
+
 define confd::file (
-    $watch_keys,
-    $ensure  = present,
-    $uid     = undef,
-    $gid     = undef,
-    $mode    = '0444',
-    $reload  = undef,
-    $check   = undef,
-    $source  = undef,
-    $content = undef,
+    $ensure     = 'present',
+    $watch_keys = [],
+    $uid        = undef,
+    $gid        = undef,
+    $mode       = '0444',
+    $reload     = undef,
+    $check      = undef,
+    $tmpl       = undef,
 ) {
-    $safe_name = regsubst($title, '\/', '_')
 
-    unless ($source or $content) {
-        fail('We either need a source file or a content for the config file')
-    }
+    $safe_name = regsubst($name, '/', '_', 'G')
+
     #TODO validate at least uid and guid
-
     file { "/etc/confd/conf.d/${safe_name}.toml":
         ensure  => $ensure,
         content => template('confd/service_template.toml.erb'),
@@ -28,8 +25,7 @@
     file { "/etc/confd/templates/${safe_name}.tmpl":
         ensure  => $ensure,
         mode    => '0400',
-        source  => $source,
-        content => $content,
+        content => template($tmpl),
         notify  => Service['confd'],
     }
 }
diff --git a/modules/confd/manifests/init.pp b/modules/confd/manifests/init.pp
index 5478a71..4a9fd62 100644
--- a/modules/confd/manifests/init.pp
+++ b/modules/confd/manifests/init.pp
@@ -43,8 +43,16 @@
     # Any change to a service configuration or to a template should reload 
confd.
     Confd::File <| |> ~> Service['confd']
 
-    nrpe::monitor_systemd_unit { 'confd':
-        require => Service['confd'],
+    if $::initsystem == 'systemd' {
+        nrpe::monitor_systemd_unit { 'confd':
+            require => Service['confd'],
+        }
+    } else {
+        nrpe::monitor_service {'confd':
+            description  => 'ensure confd service',
+            nrpe_command => '/usr/lib/nagios/plugins/check_procs -a 
/usr/bin/confd -c 1:1',
+            require      => Service['confd'],
+        }
     }
 
     # Log to a dedicated file
@@ -55,12 +63,9 @@
         mode   => '0444',
     }
 
-
     rsyslog::conf { 'confd':
         source   => 'puppet:///modules/confd/rsyslog.conf',
         priority => 20,
         require  => File['/etc/logrotate.d/confd'],
     }
-
-
 }
diff --git a/modules/confd/templates/service_template.toml.erb 
b/modules/confd/templates/service_template.toml.erb
index 646eb47..c7b457a 100644
--- a/modules/confd/templates/service_template.toml.erb
+++ b/modules/confd/templates/service_template.toml.erb
@@ -1,11 +1,17 @@
-# Confd config file for <%= @title %>
 # This file is managed by Puppet!
+# Confd config file for <%= @name %>
 [template]
 src = "<%= @safe_name %>.tmpl"
-dest = "<%= @title %>"
+dest = "<%= @name %>"
 <% if @uid %>uid = <%= @uid %><% end %>
 <% if @gid %>gid = <%= @gid %><% end %>
 mode = "<%= @mode %>"
-keys = <%= @watch_keys %>
+
+keys = [
+    <% @watch_keys.each do |key| -%>
+    "<%= key %>",
+    <% end -%>
+]
+
 <% if @check %>check_cmd = "<%= @check %> {{.src}}"<% end %>
 <% if @reload %>reload_cmd = "<%= reload %>"<% end %>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9367777879dbcebae72ef5c21b28899e9c6344b
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[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

Reply via email to