Skip to content

Commit

Permalink
Merge pull request #23 from ody/master
Browse files Browse the repository at this point in the history
Adding support for Puppetboard URLs.
  • Loading branch information
Zach Leslie committed Mar 12, 2014
2 parents a3e2dd4 + 0d3226c commit d62f078
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion hipchat.yaml
Expand Up @@ -6,4 +6,4 @@
:hipchat_proxy: 'http://username:password@proxy_host:8080'
:hipchat_statuses:
- failed

:hipchat_puppetboard: 'false'
4 changes: 4 additions & 0 deletions lib/puppet/reports/hipchat.rb
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions 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'
Expand Down
1 change: 1 addition & 0 deletions templates/hipchat.yaml.erb
Expand Up @@ -7,3 +7,4 @@
<% scope.lookupvar('puppet_hipchat::statuses').each do |status| -%>
- <%= status %>
<% end -%>
:hipchat_puppetboard: <%= scope.lookupvar('puppet_hipchat::puppetboard') %>

0 comments on commit d62f078

Please sign in to comment.