From 0d3226cdf7f112a899c5eedebd88d8d529184219 Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Wed, 12 Mar 2014 11:03:14 -0700 Subject: [PATCH] Adding support for Puppetboard URLs. This commit will add the ability to send Puppetboard URLs to your hipchat channel. --- README.md | 2 +- hipchat.yaml | 2 +- lib/puppet/reports/hipchat.rb | 4 ++++ manifests/init.pp | 1 + manifests/params.pp | 1 + templates/hipchat.yaml.erb | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e171f4..8f71b7e 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ puppet-bundled gem library: your hipchat connection details and copy the file to `/etc/puppet/` or for puppet enterpise '/etc/puppetlabs/puppet'. An option to notify users in the room `hipchat_notify` defaults to `false`. You can also change the default notification color from yellow to red, green,purple or random. The `hipchat_statuses` should be an array of statuses to send notifications - for and defaults to `'failed'`. Specify `'all'` to receive notifications from all Puppet runs. In order to send notifications through proxy server set `hipchat_proxy` to http proxy url using this format `'http://username:password@proxy_host:proxy_port'`. An example file is included. + for and defaults to `'failed'`. Specify `'all'` to receive notifications from all Puppet runs. In order to send notifications through proxy server set `hipchat_proxy` to http proxy url using this format `'http://username:password@proxy_host:proxy_port'`. If you use Puppetboard (https://github.com/nedap/puppetboard) set `hipchat_puppetboard` to the base URL of your Puppetboard installation, e.g. `'http://puppetboard.example.com'` and a link to the node's latest report will be send with the message to hipchat. An example file is included. 5. Enable pluginsync and reports on your master and clients in `puppet.conf` diff --git a/hipchat.yaml b/hipchat.yaml index 57ca637..44bc133 100644 --- a/hipchat.yaml +++ b/hipchat.yaml @@ -6,4 +6,4 @@ :hipchat_proxy: 'http://username:password@proxy_host:8080' :hipchat_statuses: - failed - +:hipchat_puppetboard: 'false' diff --git a/lib/puppet/reports/hipchat.rb b/lib/puppet/reports/hipchat.rb index 41ef718..9e27ee4 100644 --- a/lib/puppet/reports/hipchat.rb +++ b/lib/puppet/reports/hipchat.rb @@ -17,6 +17,7 @@ HIPCHAT_ROOM = config[:hipchat_room] HIPCHAT_NOTIFY = config[:hipchat_notify] HIPCHAT_STATUSES = Array(config[:hipchat_statuses] || 'failed') + HIPCHAT_PUPPETBOARD = config[:hipchat_puppetboard] # set the default colors if not defined in the config HIPCHAT_FAILED_COLOR = config[:failed_color] || 'red' @@ -65,6 +66,9 @@ def process if (HIPCHAT_STATUSES.include?(self.status) || HIPCHAT_STATUSES.include?('all')) && !disabled Puppet.debug "Sending status for #{self.host} to Hipchat channel #{HIPCHAT_ROOM}" msg = "Puppet run for #{self.host} #{emote(self.status)} #{self.status} at #{Time.now.asctime} on #{self.configuration_version} in #{self.environment}" + if HIPCHAT_PUPPETBOARD != 'false' + msg << ": #{HIPCHAT_PUPPETBOARD}/report/latest/#{self.host}" + end if HIPCHAT_PROXY client = HipChat::Client.new(HIPCHAT_API, :http_proxy => HIPCHAT_PROXY) else diff --git a/manifests/init.pp b/manifests/init.pp index a807b3d..f1a61d0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,7 @@ $provider = $puppet_hipchat::params::provider, $owner = $puppet_hipchat::params::owner, $group = $puppet_hipchat::params::group, + $puppetboard = $puppet_hipchat::params::puppetboard, ) inherits puppet_hipchat::params { file { $config_file: diff --git a/manifests/params.pp b/manifests/params.pp index 5ef4410..b39cb3c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,7 @@ class puppet_hipchat::params { $package_name = 'hipchat' + $puppetboard = 'false' if $::is_pe == 'true' { $puppetconf_path = '/etc/puppetlabs/puppet' diff --git a/templates/hipchat.yaml.erb b/templates/hipchat.yaml.erb index 86da745..43efd06 100644 --- a/templates/hipchat.yaml.erb +++ b/templates/hipchat.yaml.erb @@ -7,3 +7,4 @@ <% scope.lookupvar('puppet_hipchat::statuses').each do |status| -%> - <%= status %> <% end -%> +:hipchat_puppetboard: <%= scope.lookupvar('puppet_hipchat::puppetboard') %>