]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add slack notification for puppet
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 11 May 2018 10:54:22 +0000 (12:54 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 11 May 2018 10:54:43 +0000 (12:54 +0200)
.gitmodules
external_modules/slack [new submodule]
modules/base_installation/manifests/puppet.pp
modules/base_installation/templates/puppet/puppet.conf.erb
modules/base_installation/templates/puppet/slack.yaml.erb [new file with mode: 0644]

index 357cc1dbe45dfa4f05a9605f7ab097f784f6dc6d..0f216220e827334ddfa1636e1cb990ae4ff70491 100644 (file)
@@ -61,3 +61,6 @@
 [submodule "modules/redis"]
        path = external_modules/redis
        url = git://git.immae.eu/github/arioch/puppet-redis
+[submodule "external_modules/slack"]
+       path = external_modules/slack
+       url = git://git.immae.eu/github/cegeka/puppet-slack
diff --git a/external_modules/slack b/external_modules/slack
new file mode 160000 (submodule)
index 0000000..5abc090
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 5abc0909a05b6665d94c63771ab81620aecc1f28
index 3ca226ae404af45715fc03e74f50dcea7e5ce731..05fe9a1f2f45fd4b264008e6da91981ff705839e 100644 (file)
@@ -82,6 +82,7 @@ class base_installation::puppet (
     }
 
     $xmpp = lookup("base_installation::notify_xmpp", { "default_value" => {} })
+    $slack = lookup("base_installation::notify_slack", { "default_value" => {} })
 
     file { "$base_installation::puppet_conf_path/puppet.conf":
       content => template("base_installation/puppet/puppet.conf.erb"),
@@ -95,6 +96,13 @@ class base_installation::puppet (
       }
     }
 
+    unless empty($slack) {
+      file { "$base_installation::puppet_conf_path/slack.yaml":
+        content => template("base_installation/puppet/slack.yaml.erb"),
+        require => File[$base_installation::puppet_conf_path],
+      }
+    }
+
     if file("$base_installation::puppet_conf_path/host_ldap.info", "/dev/null") != "" and
       empty($facts["ldapvar"]) {
         fail("LDAP was activated but facts are not available")
index 03b33bba119d8fedbf9e3c4947648d486dae3708..da394686c7aa97f626c32f63fedf95ecf3df9907 100644 (file)
@@ -1,9 +1,14 @@
 [main]
-<% if @xmpp.count > 0 %>
-reports = store,xmpp
-<% else %>
-reports = store
-<% end %>
+<%
+  reports = ["store"]
+  if @xmpp.count > 0
+    reports << "xmpp"
+  end
+  if @slack.count > 0
+    reports << "slack"
+  end
+%>
+reports = <%= reports.join(",") %>
 
 basemodulepath = <%= @puppet_code_path %>/modules:<%= @puppet_code_path %>/external_modules
 
diff --git a/modules/base_installation/templates/puppet/slack.yaml.erb b/modules/base_installation/templates/puppet/slack.yaml.erb
new file mode 100644 (file)
index 0000000..bcfb9f8
--- /dev/null
@@ -0,0 +1,12 @@
+---
+:slack_webhook: '<%= @slack["webhook"] %>'
+:slack_channel: '<%= @slack["channel"] %>'
+:slack_username: '<%= @slack["username"] %>'
+:slack_icon_url: '<%= @slack["icon_url"] %>'
+:slack_statuses:
+<% @slack["statuses"].each do |status| %>
+  - <%= status %>
+<% end %>
+:foreman_api_host: ~
+:puppetboard_api_host: ~
+