From cdbbfd477be98497ca89233ca8b8b1c1e27e184b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 22 Mar 2018 11:50:12 +0100 Subject: [PATCH] XMPP notification --- .gitmodules | 3 +++ environments/global/common.yaml | 1 + modules/base_installation/manifests/puppet.pp | 18 +++++++++++++++++- .../templates/puppet/puppet.conf.erb | 5 +++++ .../templates/puppet/xmpp.yaml.erb | 11 +++++++++++ modules/xmpp | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 modules/base_installation/templates/puppet/xmpp.yaml.erb create mode 160000 modules/xmpp diff --git a/.gitmodules b/.gitmodules index 735ca8c..7a56af5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,6 +49,9 @@ [submodule "modules/ssh_keygen"] path = modules/ssh_keygen url = git://git.immae.eu/github/voxpupuli/puppet-ssh_keygen +[submodule "modules/xmpp"] + path = modules/xmpp + url = git://git.immae.eu/github/jamtur01/puppet-xmpp [submodule "modules/ssl"] path = modules/ssl url = git://git.immae.eu/github/fnerdwq/puppet-ssl diff --git a/environments/global/common.yaml b/environments/global/common.yaml index 094e0ff..2dfe0aa 100644 --- a/environments/global/common.yaml +++ b/environments/global/common.yaml @@ -29,6 +29,7 @@ base_installation::puppet_ssl_path: "/etc/puppetlabs/ssl" base_installation::system_locales: ["fr_FR.UTF-8", "en_US.UTF-8"] base_installation::system_timezone: "Europe/Paris" base_installation::system_users: [] # Fetched via ldap +base_installation::notify_xmpp: {} profile::fstab::mounts: - "%{facts.ldapvar.self.vars.mounts.0}" - "%{facts.ldapvar.self.vars.mounts.1}" diff --git a/modules/base_installation/manifests/puppet.pp b/modules/base_installation/manifests/puppet.pp index 0cb43bc..c64ddfd 100644 --- a/modules/base_installation/manifests/puppet.pp +++ b/modules/base_installation/manifests/puppet.pp @@ -56,23 +56,39 @@ class base_installation::puppet ( install_options => "--no-user-install" } + package { 'gem:xmpp4r': + name => "xmpp4r", + ensure => present, + provider => "gem", + install_options => "--no-user-install" + } + file { $password_seed: mode => "0600", } file { $base_installation::puppet_conf_path: ensure => directory, - require => [Package["puppet"], Package["gem:ruby-ldap"]], + require => [Package["puppet"], Package["gem:xmpp4r"], Package["gem:ruby-ldap"]], recurse => true, purge => true, force => true, } + $xmpp = lookup("base_installation::notify_xmpp", { "default_value" => {} }) + file { "$base_installation::puppet_conf_path/puppet.conf": content => template("base_installation/puppet/puppet.conf.erb"), require => File[$base_installation::puppet_conf_path], } + unless empty($xmpp) { + file { "$base_installation::puppet_conf_path/xmpp.yaml": + content => template("base_installation/puppet/xmpp.yaml.erb"), + require => File[$base_installation::puppet_conf_path], + } + } + $ips = lookup("ips", { 'default_value' => undef }) file { "$base_installation::puppet_conf_path/host_ldap.info": content => template("base_installation/puppet/host_ldap.info.erb"), diff --git a/modules/base_installation/templates/puppet/puppet.conf.erb b/modules/base_installation/templates/puppet/puppet.conf.erb index 24e67c8..37eba8e 100644 --- a/modules/base_installation/templates/puppet/puppet.conf.erb +++ b/modules/base_installation/templates/puppet/puppet.conf.erb @@ -1,4 +1,9 @@ [main] +<% if @xmpp.count > 0 %> +reports = store,xmpp +<% else %> +reports = store +<% end %> ssldir = <%= @puppet_ssl_path %> environment = <%= @environment %> diff --git a/modules/base_installation/templates/puppet/xmpp.yaml.erb b/modules/base_installation/templates/puppet/xmpp.yaml.erb new file mode 100644 index 0000000..572f472 --- /dev/null +++ b/modules/base_installation/templates/puppet/xmpp.yaml.erb @@ -0,0 +1,11 @@ +:xmpp_password: "<%= @xmpp["password"] %>" +:xmpp_jid: "<%= @xmpp["jid"] %>/<%= @real_hostname %>" +:xmpp_target: "<%= @xmpp["target"] %>" +<% if @xmpp["statuses"].is_a?(String) %> +:xmpp_statuses: "<%= @xmpp["statuses"] %>" +<% else %> +:xmpp_statuses: +<% @xmpp["statuses"].each do |status| %> + - <%= status %> +<% end %> +<% end %> diff --git a/modules/xmpp b/modules/xmpp new file mode 160000 index 0000000..d18dd07 --- /dev/null +++ b/modules/xmpp @@ -0,0 +1 @@ +Subproject commit d18dd07ffdf6c33942bd0c277cb24aafa513cbd7 -- 2.41.0