aboutsummaryrefslogtreecommitdiff
path: root/modules/base_installation
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-11 12:54:22 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-11 12:54:43 +0200
commitc8511b2019b44360887d33a9626ec14c81736aee (patch)
tree68826f98d5e040c34dbc249570d306664020de5c /modules/base_installation
parent5a5b32d87d06cfc6dce82cf83cb023ed2764fc45 (diff)
downloadPuppet-c8511b2019b44360887d33a9626ec14c81736aee.tar.gz
Puppet-c8511b2019b44360887d33a9626ec14c81736aee.tar.zst
Puppet-c8511b2019b44360887d33a9626ec14c81736aee.zip
Add slack notification for puppet
Diffstat (limited to 'modules/base_installation')
-rw-r--r--modules/base_installation/manifests/puppet.pp8
-rw-r--r--modules/base_installation/templates/puppet/puppet.conf.erb15
-rw-r--r--modules/base_installation/templates/puppet/slack.yaml.erb12
3 files changed, 30 insertions, 5 deletions
diff --git a/modules/base_installation/manifests/puppet.pp b/modules/base_installation/manifests/puppet.pp
index 3ca226a..05fe9a1 100644
--- a/modules/base_installation/manifests/puppet.pp
+++ b/modules/base_installation/manifests/puppet.pp
@@ -82,6 +82,7 @@ class base_installation::puppet (
82 } 82 }
83 83
84 $xmpp = lookup("base_installation::notify_xmpp", { "default_value" => {} }) 84 $xmpp = lookup("base_installation::notify_xmpp", { "default_value" => {} })
85 $slack = lookup("base_installation::notify_slack", { "default_value" => {} })
85 86
86 file { "$base_installation::puppet_conf_path/puppet.conf": 87 file { "$base_installation::puppet_conf_path/puppet.conf":
87 content => template("base_installation/puppet/puppet.conf.erb"), 88 content => template("base_installation/puppet/puppet.conf.erb"),
@@ -95,6 +96,13 @@ class base_installation::puppet (
95 } 96 }
96 } 97 }
97 98
99 unless empty($slack) {
100 file { "$base_installation::puppet_conf_path/slack.yaml":
101 content => template("base_installation/puppet/slack.yaml.erb"),
102 require => File[$base_installation::puppet_conf_path],
103 }
104 }
105
98 if file("$base_installation::puppet_conf_path/host_ldap.info", "/dev/null") != "" and 106 if file("$base_installation::puppet_conf_path/host_ldap.info", "/dev/null") != "" and
99 empty($facts["ldapvar"]) { 107 empty($facts["ldapvar"]) {
100 fail("LDAP was activated but facts are not available") 108 fail("LDAP was activated but facts are not available")
diff --git a/modules/base_installation/templates/puppet/puppet.conf.erb b/modules/base_installation/templates/puppet/puppet.conf.erb
index 03b33bb..da39468 100644
--- a/modules/base_installation/templates/puppet/puppet.conf.erb
+++ b/modules/base_installation/templates/puppet/puppet.conf.erb
@@ -1,9 +1,14 @@
1[main] 1[main]
2<% if @xmpp.count > 0 %> 2<%
3reports = store,xmpp 3 reports = ["store"]
4<% else %> 4 if @xmpp.count > 0
5reports = store 5 reports << "xmpp"
6<% end %> 6 end
7 if @slack.count > 0
8 reports << "slack"
9 end
10%>
11reports = <%= reports.join(",") %>
7 12
8basemodulepath = <%= @puppet_code_path %>/modules:<%= @puppet_code_path %>/external_modules 13basemodulepath = <%= @puppet_code_path %>/modules:<%= @puppet_code_path %>/external_modules
9 14
diff --git a/modules/base_installation/templates/puppet/slack.yaml.erb b/modules/base_installation/templates/puppet/slack.yaml.erb
new file mode 100644
index 0000000..bcfb9f8
--- /dev/null
+++ b/modules/base_installation/templates/puppet/slack.yaml.erb
@@ -0,0 +1,12 @@
1---
2:slack_webhook: '<%= @slack["webhook"] %>'
3:slack_channel: '<%= @slack["channel"] %>'
4:slack_username: '<%= @slack["username"] %>'
5:slack_icon_url: '<%= @slack["icon_url"] %>'
6:slack_statuses:
7<% @slack["statuses"].each do |status| %>
8 - <%= status %>
9<% end %>
10:foreman_api_host: ~
11:puppetboard_api_host: ~
12