Giter Site home page Giter Site logo

chef-hipchat's Introduction

chef-hipchat

Description

This cookbook provides a hipchat_msg resource, making it easier for chef recipes to send messages to a chat room on Atlassian's HipChat service.

Platform

Should work on any platform where Chef runs. Tested on Ubuntu.

Requirements

  • Chef version 11.10 or greater (JSON gem version conflicts)
  • Authentication token for an existing HipChat account.
  • 'hipchat' gem (automatically installed by this cookbook's default recipe).

Actions

  • speak - do it (the default)
  • nothing - don't do it

Attributes

  • api_version - version of hipchat api to use. allowed values are 'v1' and 'v2' (defaults to 'v1').
  • room - the name of the room you would like to speak into (requied).
  • token - authentication token for your HipChat account (required). Please note that auth tokens are tied to api versions (e.g. v1 tokens will not work with v2 api).
  • nickname - the nickname to be used when speaking the message (required).
  • message - the message to speak. If a message is not specified, the name of the hipchat_msg resource is used.
  • notify - toggles whether or not users in the room should be notified by this message (defaults to true).
  • color - sets the color of the message in HipChat. Supported colors include: yellow, red, green, purple, or random (defaults to yellow).
  • failure_ok - toggles whether or not to catch the exception if an error is encountered connecting to HipChat (defaults to true).

Usage example

include_recipe 'hipchat'

hipchat_msg 'bad news' do
  room 'The Pod Bay'
  token '0xdedbeef0xdedbeef0xdedbeef'
  nickname 'HAL9000'
  message "Sorry Dave, I'm afraid I can't do that: #{some_error}"
  color 'red'
end

License and Author

Author:: Cameron Johnston [email protected]

Copyright:: 2012, Cameron Johnston

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

chef-hipchat's People

Contributors

bcg62 avatar cwjohnston avatar jarosser06 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

chef-hipchat's Issues

LWRP not speaking?

I am using the LWRP like this:

hipchat_msg 'deployment' do
  room 'CI'
  token node['hipchat-token']
  message "Successful deployment of #{node['web']['revision']} branch on #{node['app']['name']}-#{node.chef_environment}"
  color 'green'
end

but in the run I only get hipchat_msg[deployment] action speak (up to date) and nothing appears in the room. Do I have to notify from another resource?

Issue with handler recipe with chef-client 12.7.2

When converging a cookbook using the hipchat resource the converge fails with the error below.
This is using chef-client 12.7.2. This doesn't seem to affect chef-client 12.6 or below.
Tested using Vagrant with CentOS 6.6.

https://github.com/cwjohnston/chef-hipchat/blob/master/recipes/handler.rb#L38

Recipe: hipchat::handler
(up to date)
* cookbook_file[/tmp/kitchen/handlers/hipchat.rb] action create

       ================================================================================
       Error executing action `create` on resource 'cookbook_file[/tmp/kitchen/handlers/hipchat.rb]'
       ================================================================================

       TypeError
       ---------
       no implicit conversion of Chef::DelayedEvaluator into String

       Cookbook Trace:
       ---------------
       /tmp/kitchen/cache/cookbooks/hipchat/recipes/handler.rb:38:in `from_file'

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/hipchat/recipes/handler.rb

        32: cookbook_file handler_file do
        33:   source 'handler.rb'
        34:   owner 'root'
        35:   group 'root'
        36:   mode '644'
        37:   action :nothing
        38: end.run_action(:create)
        39:
        40: handler = node['hipchat']['handler']
        41: handler_options = {
        42:   :server_url => handler['server'],
        43:   :name => handler['name'],
        44:   :notify_users => handler['notify_users'],
        45:   :color => handler['color'],
        46:   :api_version => handler['api_version']
        47: }
        48:
        49: chef_handler 'HipChat::NotifyRoom' do
        50:   source handler_file
        51:   supports({:exception => true})
        52:   arguments [ handler['token'], handler['room'], handler_options ]
        53:   action :nothing
        54: end.run_action(node['hipchat']['handler']['enabled'] ? :enable : :disable)

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen/cache/cookbooks/hipchat/recipes/handler.rb:32:in `from_file'

       cookbook_file("/tmp/kitchen/handlers/hipchat.rb") do
         provider Chef::Provider::CookbookFile
         action [:nothing]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         source "handler.rb"
         declared_type "cookbook_file"
         cookbook_name "hipchat"
         recipe_name "handler"
         owner "root"
         group "root"
         mode "644"
         atomic_update #<Chef::DelayedEvaluator:0x00000003984970@/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/resource/file.rb:52>
         path #<Chef::DelayedEvaluator:0x00000003985a50@/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/property.rb:177>
       end


     TypeError
     ---------
     cookbook_file[/tmp/kitchen/handlers/hipchat.rb] (hipchat::handler line 32) had an error: TypeError: no implicit conversion of Chef::DelayedEvaluator into String

     Cookbook Trace:
     ---------------
       /tmp/kitchen/cache/cookbooks/hipchat/recipes/handler.rb:38:in `from_file'

     Relevant File Content:
     ----------------------
     /tmp/kitchen/cache/cookbooks/hipchat/recipes/handler.rb:

      31:
      32:  cookbook_file handler_file do
      33:    source 'handler.rb'
      34:    owner 'root'
      35:    group 'root'
      36:    mode '644'
      37:    action :nothing
      38>> end.run_action(:create)
      39:
      40:  handler = node['hipchat']['handler']
      41:  handler_options = {
      42:    :server_url => handler['server'],
      43:    :name => handler['name'],
      44:    :notify_users => handler['notify_users'],
      45:    :color => handler['color'],
      46:    :api_version => handler['api_version']
      47:  }


     Running handlers:
   [2016-02-29T08:42:31+00:00] ERROR: Running exception handlers
     Running handlers complete
   [2016-02-29T08:42:31+00:00] ERROR: Exception handlers complete

Message formatting?

Is there a way to format the message passed to Hipchat? I tried adding newlines without success.

Gem dependency prevents proper installation

Trying to use this on opswork, and I'm probably missing something.

I literally copied the repo (ex .gitignore) into my cookbooks under dir "hipchat". In my deploy/recipes/default.rb add

include_recipe 'hipchat'
  hipchat_msg 'bad news' do
      room 'web'
      token 'my_token'
      nickname 'opswork'
      message "Problem with deployment: #{some_error}.  Check it out."
      color 'red'
    end
end

Then in deploy/metadata.rb, I added line:

depends "hipchat"

Am I supposed to reference where the gems need to be installed from? Is there an equivalent gemfile I need to fix?

[2013-08-16T23:33:35+00:00] DEBUG: Gem::InstallError: ruby_block[Compile Custom OpsWorks Run List] (opsworks_custom_cookbooks::execute line 3) had an error: Gem::InstallError: chef_gem[hipchat] (hipchat::default line 1) had an error: Gem::InstallError: httparty requires multi_xml (>= 0.5.2)
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:232:in `ensure_dependency'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:408:in `ensure_dependencies_met'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:407:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:407:in `ensure_dependencies_met'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:158:in `install'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:297:in `install'
/usr/lib/ruby/1.8/fileutils.rb:243:in `each_with_index'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:270:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:270:in `each_with_index'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:270:in `install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:169:in `install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:192:in `with_correct_verbosity'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:168:in `install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:103:in `with_gem_sources'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:167:in `install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package/rubygems.rb:476:in `install_package'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package.rb:82:in `action_install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/mixin/why_run.rb:52:in `call'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:151:in `converge_by'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/package.rb:80:in `action_install'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:114:in `send'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:114:in `run_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource.rb:617:in `run_action'
/opt/aws/opsworks/releases/20130806085854_205/site-cookbooks/hipchat/recipes/default.rb:11:in `from_file'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/cookbook_version.rb:346:in `load_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:151:in `load_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:132:in `include_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:131:in `each'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:131:in `include_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
/opt/aws/opsworks/releases/20130806085854_205/site-cookbooks/deploy/recipes/default.rb:2:in `from_file'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/cookbook_version.rb:346:in `load_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:151:in `load_recipe'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context/cookbook_compiler.rb:139:in `compile_recipes'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context/cookbook_compiler.rb:137:in `each'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context/cookbook_compiler.rb:74:in `compile'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/run_context.rb:86:in `load'
/opt/aws/opsworks/releases/20130806085854_205/site-cookbooks/opsworks_custom_cookbooks/recipes/execute.rb:15:in `from_file'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/ruby_block.rb:33:in `call'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/ruby_block.rb:33:in `action_run'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/mixin/why_run.rb:52:in `call'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:151:in `converge_by'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider/ruby_block.rb:32:in `action_run'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:114:in `send'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/provider.rb:114:in `run_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource.rb:617:in `run_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/runner.rb:50:in `run_action'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/runner.rb:82:in `converge'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/runner.rb:82:in `each'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/runner.rb:82:in `converge'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection.rb:94:in `execute_each_resource'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/runner.rb:81:in `converge'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/client.rb:404:in `converge'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/client.rb:469:in `do_run'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/client.rb:200:in `run'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/application.rb:190:in `run_chef_client'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/application/solo.rb:239:in `run_application'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/application/solo.rb:231:in `loop'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/application/solo.rb:231:in `run_application'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/../lib/chef/application.rb:73:in `run'
/opt/aws/opsworks/releases/20130806085854_205/vendor/gems/chef-11.4.4/bin/chef-solo:25
/opt/aws/opsworks/current/bin/chef-solo:16:in `load'
/opt/aws/opsworks/current/bin/chef-solo:16
[2013-08-16T23:33:35+00:00] FATAL: Gem::InstallError: ruby_block[Compile Custom OpsWorks Run List] (opsworks_custom_cookbooks::execute line 3) had an error: Gem::InstallError: chef_gem[hipchat] (hipchat::default line 1) had an error: Gem::InstallError: httparty requires multi_xml (>= 0.5.2)

Not working with HipChat Server v1.1.4

I'm not sure if this is an issue with this Cookbook or HipChat Server v1.1.4, but I am no longer able to send messages to rooms. Has anyone else encountered this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.