├── .fixtures.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── hipchat.yaml ├── lib └── puppet │ └── reports │ └── hipchat.rb ├── manifests ├── init.pp └── params.pp ├── metadata.json ├── spec ├── acceptance │ ├── hipchat_spec.rb │ └── nodesets │ │ ├── centos-6-x64.yml │ │ ├── centos-7-x64.yml │ │ ├── debian-7-x64.yml │ │ ├── debian-8-x64.yml │ │ ├── docker │ │ ├── centos-6.yml │ │ ├── centos-7.yml │ │ ├── debian-7.yml │ │ ├── debian-8.yml │ │ ├── ubuntu-12.04.yml │ │ ├── ubuntu-14.04.yml │ │ └── ubuntu-16.04.yml │ │ ├── ubuntu-12.04-x64.yml │ │ ├── ubuntu-14.04-x64.yml │ │ └── ubuntu-16.04-x64.yml ├── classes │ └── puppet_init_spec.rb ├── spec_helper.rb └── spec_helper_acceptance.rb └── templates └── hipchat.yaml.erb /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git 4 | symlinks: 5 | puppet_hipchat: "#{source_dir}" 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | spec/fixtures 2 | pkg/* 3 | .bundle 4 | Gemfile.lock 5 | .vagrant 6 | junit 7 | log 8 | .swp 9 | 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: ruby 4 | bundler_args: --without system_tests 5 | script: 6 | - "bundle exec rake validate" 7 | - "bundle exec rake lint" 8 | - "bundle exec rake spec SPEC_OPTS='--format documentation --order random'" 9 | before_install: 10 | - gem update --system 2.1.11 11 | - gem --version 12 | matrix: 13 | fast_finish: true 14 | include: 15 | # spec tests 16 | - rvm: 1.9.3 17 | env: PUPPET_GEM_VERSION="~> 3.0" 18 | - rvm: 2.0.0 19 | env: PUPPET_GEM_VERSION="~> 3.0" 20 | - rvm: 2.0.0 21 | env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" 22 | - rvm: 2.1.7 23 | env: PUPPET_GEM_VERSION="~> 4.0" 24 | 25 | # beaker tests 26 | - rvm: default 27 | sudo: required 28 | services: docker 29 | env: BEAKER_set="docker/centos-6" 30 | bundler_args: 31 | script: travis_wait bundle exec rspec spec/acceptance/*_spec.rb 32 | - rvm: default 33 | sudo: required 34 | services: docker 35 | env: BEAKER_set="docker/centos-7" 36 | bundler_args: 37 | script: travis_wait bundle exec rspec spec/acceptance/*_spec.rb 38 | - rvm: default 39 | sudo: required 40 | services: docker 41 | env: BEAKER_set="docker/debian-8" 42 | bundler_args: 43 | script: travis_wait bundle exec rspec spec/acceptance/*_spec.rb 44 | - rvm: default 45 | sudo: required 46 | services: docker 47 | env: BEAKER_set="docker/ubuntu-16.04" 48 | bundler_args: 49 | script: travis_wait bundle exec rspec spec/acceptance/*_spec.rb 50 | notifications: 51 | email: 52 | - james@lovedthanlost.net 53 | - powisj@gmail.com 54 | 55 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Checklist (abreviated) 2 | ====================== 3 | 4 | * Commits: 5 | 6 | - Commits should be logically grouped. Do not have multiple unrelated changes in a single commit. 7 | 8 | - Avoid unnesscessary whitespace additions. Use "git diff --check" before committing. 9 | - Avoid checking in commented code or nonrelevant files. 10 | 11 | - The first line of the commit message should be less than 50 characters and is the title of the change. Additional details may be included on additional lines. 12 | 13 | - Associate the Issue ID on the first line of the commit message in the form of "(#XXX) Rest of Message" 14 | 15 | - The body of the commit message should be meaningful and provide enough detail as to why the change was needed. 16 | 17 | * Submission: 18 | 19 | * Preferred Method: 20 | 21 | - Fork the repository on GitHub. 22 | 23 | - Push your changes to a topic branch in your fork of the repository. (the format ticket/1234-short_description_of change is usually preferred. 24 | 25 | - Submit a pull request to the repository. 26 | 27 | - Contributions will only be accepted if spec / acceptance tests are included and passing. If you require assistance please submit the request and ask for advice. 28 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || "https://rubygems.org" 2 | 3 | group :development, :unit_tests do 4 | gem 'json', :require => false 5 | gem 'metadata-json-lint', :require => false 6 | gem 'puppet-lint', :require => false 7 | gem 'puppet-syntax', :require => false 8 | gem 'puppetlabs_spec_helper', :require => false 9 | gem 'rake', :require => false 10 | gem 'rspec-puppet', :require => false 11 | end 12 | 13 | group :system_tests do 14 | gem 'vagrant-wrapper', :require => false 15 | gem 'beaker', :require => false 16 | gem 'specinfra', :require => false 17 | gem 'beaker-rspec', :require => false 18 | gem 'serverspec', :require => false 19 | end 20 | 21 | if facterversion = ENV['FACTER_GEM_VERSION'] 22 | gem 'facter', facterversion, :require => false 23 | else 24 | gem 'facter', :require => false 25 | end 26 | 27 | if puppetversion = ENV['PUPPET_GEM_VERSION'] 28 | gem 'puppet', puppetversion, :require => false 29 | else 30 | gem 'puppet', :require => false 31 | end 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Puppet Hipchat 2 | 3 | [![Puppet Forge](http://img.shields.io/puppetforge/v/jamtur01/puppet_hipchat.svg)](https://forge.puppetlabs.com/jamtur01/puppet_hipchat) 4 | [![Puppet Forge downloads](https://img.shields.io/puppetforge/dt/jamtur01/puppet_hipchat.svg)](https://forge.puppetlabs.com/jamtur01/puppet_hipchat) 5 | [![Puppet Forge score](https://img.shields.io/puppetforge/f/jamtur01/puppet_hipchat.svg)](https://forge.puppetlabs.com/jamtur01/puppet_hipchat) 6 | [![Build Status](https://travis-ci.org/jamtur01/puppet-hipchat.svg?branch=master)](https://travis-ci.org/jamtur01/puppet-hipchat) 7 | 8 | 9 | ## **Migrated** 10 | 11 | **This module has been migrated to voxpupuli: [https://github.com/voxpupuli/puppet-report_hipchat](https://github.com/voxpupuli/puppet-report_hipchat)** 12 | 13 | ## Description 14 | 15 | A Puppet report handler for sending notifications of Puppet runs to [HipChat](http://www.hipchat.com). 16 | 17 | ## TravisCI status 18 | 19 | [![Build Status](https://travis-ci.org/jamtur01/puppet-hipchat.svg?branch=master)](https://travis-ci.org/jamtur01/puppet-hipchat) 20 | 21 | ## Requirements 22 | 23 | * `ruby >= 1.9.3` Note: PE puppet-master 3.x and PE/opensource puppetserver bundled versions of ruby should meet required version. 24 | * `hipchat >= 0.12.0` 25 | * `puppet` 26 | 27 | For Cent/RHEL 6 users running open source puppet-master 3.x, puppet utilizes the system ruby as such the latest repository provided version of ruby is 1.8.7, this means use of RVM or some other method to install a modern version of ruby will be required. 28 | 29 | For the room in which you want to receive puppet notifications, add a new BYO Integration. This will return an example url: `https://example.hipchat.com/v2/room/123456789/notification?auth_token=WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S` 30 | `https://example.hipchat.com` is the server (you can use on premise hipchat servers as well) 31 | `v2` is the api version 32 | `123456789` is the room 33 | `WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S` is the api_key 34 | 35 | ## Installation 36 | 37 | ### Installation utilizing puppet 38 | 39 | ```puppet 40 | class { 'puppet_hipchat': 41 | server => 'https://example.hipchat.com', 42 | api_version => 'v2', 43 | api_key => 'WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S', 44 | room => '123456789', 45 | install_hc_gem => true, 46 | provider => 'puppetserver_gem', 47 | } 48 | ``` 49 | 50 | With puppetboard link: 51 | 52 | ```puppet 53 | class { 'puppet_hipchat': 54 | server => 'https://example.hipchat.com', 55 | api_version => 'v2', 56 | api_key => 'WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S', 57 | room => '123456789', 58 | install_hc_gem => true, 59 | provider => 'puppetserver_gem', 60 | puppetboard => 'https://puppetboard.test.local', 61 | } 62 | ``` 63 | 64 | With dashboard link: 65 | 66 | ```puppet 67 | class { 'puppet_hipchat': 68 | server => 'https://example.hipchat.com', 69 | api_version => 'v2', 70 | api_key => 'WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S', 71 | room => '123456789', 72 | install_hc_gem => true, 73 | provider => 'puppetserver_gem', 74 | dashboard => 'https://dashboard.test.local', 75 | } 76 | ``` 77 | 78 | If you need to use a proxy to reach the hipchat server: 79 | 80 | ```puppet 81 | class { 'puppet_hipchat': 82 | server => 'https://example.hipchat.com', 83 | api_version => 'v2', 84 | api_key => 'WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S', 85 | room => '123456789', 86 | install_hc_gem => true, 87 | provider => 'puppetserver_gem', 88 | proxy => 'http://proxy.test.local:8080', 89 | } 90 | ``` 91 | 92 | Where provider is the following: 93 | * `puppetserver_gem` used for opensource and pe puppetserver requires [puppetlabs-pe_gem](https://forge.puppet.com/puppetlabs/puppetserver_gem) 94 | * `pe_gem` used for PE puppet master 3.x requires [puppetlabs-pe_gem](https://forge.puppet.com/puppetlabs/pe_gem) 95 | * `gem` used for opensource puppet-master 96 | 97 | Lastly Enable pluginsync and reports on your master and clients in `puppet.conf` 98 | 99 | [master] 100 | report = true 101 | reports = hipchat 102 | pluginsync = true 103 | [agent] 104 | report = true 105 | pluginsync = true 106 | 107 | ### Manual Installation 108 | 109 | 1. Install the `hipchat` gem on your Puppet server 110 | 111 | *NOTE FOR PE/Open Source puppetserver package 2.0.0+ USERS*: You must install the `hipchat` gem using the 112 | puppetserver gem utility: 113 | 114 | $ /opt/puppetlabs/bin/puppetserver gem install hipchat 115 | 116 | *NOTE FOR PE puppet-master USERS*: You must install the `hipchat` gem using the 117 | puppet-bundled gem library: 118 | 119 | $ /opt/puppet/bin/gem install hipchat 120 | 121 | *NOTE FOR Open Source puppet-master USERS*: You must install the `hipchat` gem using the system gem utility: 122 | 123 | $ sudo gem install hipchat 124 | 125 | 126 | 2. Install puppet-hipchat as a module in your Puppet master's module 127 | path. 128 | 129 | 3. Update the `hipchat_server`, `hipchat_api_version`, `hipchat_api`, `hipchat_room` variables in the 130 | `hipchat.yaml` file with your Hipchat connection details and copy 131 | the file to `/etc/puppet/` or for PE/OpenSource puppetserver 132 | `/etc/puppetlabs/puppet`. 133 | 134 | --- 135 | :hipchat_server: 'https://test.hipchat.com' 136 | :hipchat_api_version: 'v2', 137 | :hipchat_api: 'WzP0dc4oEESuSmF2WJT23GtL5mili9uXof73M48S' 138 | :hipchat_room: '123456789' 139 | 140 | 141 | 4. Enable pluginsync and reports on your master and clients in `puppet.conf` 142 | 143 | [master] 144 | report = true 145 | reports = hipchat 146 | pluginsync = true 147 | [agent] 148 | report = true 149 | pluginsync = true 150 | 151 | 6. Run the Puppet client and sync the report as a plugin 152 | 153 | Usage 154 | ----- 155 | 156 | * An option to notify users in the room `hipchat_notify` defaults to 157 | `false`. 158 | 159 | * You can also change the default notification color from yellow to red, 160 | green, purple or random. 161 | 162 | * The `hipchat_statuses` should be an array of statuses to send 163 | notifications for and defaults to `'failed'`. Specify `'all'` to 164 | receive notifications from all Puppet runs. 165 | 166 | * In order to send notifications through proxy server set 167 | `hipchat_proxy` to your HTTP proxy URL using this format: 168 | 169 | 'http://username:password@proxy_host:proxy_port' 170 | 171 | * If you use [Puppetboard](https://github.com/nedap/puppetboard) set 172 | `hipchat_puppetboard` to the base URL of your Puppetboard 173 | installation, e.g. `'http://puppetboard.example.com'` and a link to the 174 | node's latest report will be send with the message to HipChat. An 175 | example file is included. 176 | 177 | *NOTE FOR PUPPETBOARD 0.1.2+ USERS*: if you are using environments other than production 178 | you will need to either configure puppetboard default environment to * or set `hipchat_server` 179 | to append /%2A, ex: `:hipchat_server: http://hipchat.test.local/%2A` otherwise you will receive 180 | a not found error for any nodes in environments other than `production`. 181 | 182 | * To temporarily disable HipChat notifications add a file named 183 | `hipchat_disabled` in the same path as `hipchat.yaml`. Removing it 184 | will re-enable notifications. 185 | 186 | $ touch /etc/puppet/hipchat_disabled 187 | 188 | Team 189 | ---- 190 | 191 | Maintainer: [James Powis](https://github.com/james-powis) 192 | 193 | Original author: James Turnbull 194 | 195 | License 196 | ------- 197 | 198 | Author:: James Turnbull () 199 | Copyright:: Copyright (c) 2011 James Turnbull 200 | License:: Apache License, Version 2.0 201 | 202 | Licensed under the Apache License, Version 2.0 (the "License"); 203 | you may not use this file except in compliance with the License. 204 | You may obtain a copy of the License at 205 | 206 | http://www.apache.org/licenses/LICENSE-2.0 207 | 208 | Unless required by applicable law or agreed to in writing, software 209 | distributed under the License is distributed on an "AS IS" BASIS, 210 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 211 | See the License for the specific language governing permissions and 212 | limitations under the License. 213 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' if RUBY_VERSION < '1.9.0' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | require 'puppet-lint/tasks/puppet-lint' 4 | require 'puppet-syntax/tasks/puppet-syntax' 5 | 6 | begin 7 | require 'puppet_blacksmith/rake_tasks' 8 | rescue LoadError 9 | end 10 | 11 | exclude_paths = [ 12 | "pkg/**/*", 13 | "vendor/**/*", 14 | "spec/**/*", 15 | ] 16 | 17 | PuppetLint.configuration.relative = true 18 | PuppetLint.configuration.fail_on_warnings 19 | PuppetLint.configuration.ignore_paths = exclude_paths 20 | PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" 21 | PuppetLint.configuration.send('relative') 22 | PuppetLint.configuration.send('disable_80chars') 23 | PuppetLint.configuration.send('disable_class_inherits_from_params_class') 24 | PuppetSyntax.exclude_paths = exclude_paths 25 | 26 | desc "Run acceptance tests" 27 | RSpec::Core::RakeTask.new(:acceptance) do |t| 28 | t.pattern = 'spec/acceptance' 29 | end 30 | 31 | task :metadata do 32 | sh "metadata-json-lint metadata.json" 33 | end 34 | 35 | desc "Run syntax, lint, and spec tests." 36 | task :test => [ 37 | :syntax, 38 | :lint, 39 | :metadata, 40 | :spec, 41 | ] 42 | -------------------------------------------------------------------------------- /hipchat.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :hipchat_api: 'apikey' 3 | :hipchat_api_version: 'v1' 4 | :hipchat_room: 'roomname' 5 | :hipchat_notify_color: 'red' 6 | :hipchat_notify: 'false' 7 | :hipchat_proxy: 'http://username:password@proxy_host:8080' 8 | :hipchat_statuses: 9 | - failed 10 | :hipchat_puppetboard: 'false' 11 | -------------------------------------------------------------------------------- /lib/puppet/reports/hipchat.rb: -------------------------------------------------------------------------------- 1 | require 'puppet' 2 | require 'yaml' 3 | 4 | begin 5 | require 'hipchat' 6 | rescue LoadError 7 | Puppet.warning "You need the `hipchat` gem to use the Hipchat report" 8 | end 9 | 10 | Puppet::Reports.register_report(:hipchat) do 11 | 12 | configfile = File.join([File.dirname(Puppet.settings[:config]), "hipchat.yaml"]) 13 | raise(Puppet::ParseError, "Hipchat report config file #{configfile} not readable") unless File.exist?(configfile) 14 | config = YAML.load_file(configfile) 15 | 16 | #due to previous code stringifying false in place of undef we need to hard set those values to undef if 'false' for backward compatibility 17 | if config[:hipchat_dashboard] == 'false' 18 | config.delete(':hipchat_dashboard') 19 | end 20 | if config[:hipchat_dashboard] == 'false' 21 | config.delete(':hipchat_dashboard') 22 | end 23 | if config[:hipchat_proxy] == 'false' 24 | config.delete(':hipchat_proxy') 25 | end 26 | 27 | HIPCHAT_API = config[:hipchat_api] 28 | HIPCHAT_SERVER = config[:hipchat_server] 29 | HIPCHAT_ROOM = config[:hipchat_room] 30 | HIPCHAT_NOTIFY = config[:hipchat_notify] 31 | HIPCHAT_STATUSES = Array(config[:hipchat_statuses] || 'failed') 32 | HIPCHAT_PUPPETBOARD = config[:hipchat_puppetboard] 33 | HIPCHAT_DASHBOARD = config[:hipchat_dashboard] 34 | HIPCHAT_API_VERSION = config[:hipchat_api_version] || 'v1' 35 | 36 | # set the default colors if not defined in the config 37 | HIPCHAT_FAILED_COLOR = config[:failed_color] || 'red' 38 | HIPCHAT_CHANGED_COLOR = config[:successful_color] || 'green' 39 | HIPCHAT_UNCHANGED_COLOR = config[:unchanged_color] || 'gray' 40 | 41 | DISABLED_FILE = File.join([File.dirname(Puppet.settings[:config]), 'hipchat_disabled']) 42 | HIPCHAT_PROXY = config[:hipchat_proxy] || ENV['http_proxy'] 43 | 44 | if HIPCHAT_PROXY && (RUBY_VERSION < '1.9.3' || Gem.loaded_specs["hipchat"].version < Gem::Version.new('1.0.0')) 45 | raise(Puppet::SettingsError, "hipchat_proxy requires ruby >= 1.9.3 and hipchat gem >= 1.0.0") 46 | end 47 | 48 | desc <<-DESC 49 | Send notification of puppet runs to a Hipchat room. 50 | DESC 51 | 52 | def color(status) 53 | case status 54 | when 'failed' 55 | HIPCHAT_FAILED_COLOR 56 | when 'changed' 57 | HIPCHAT_CHANGED_COLOR 58 | when 'unchanged' 59 | HIPCHAT_UNCHANGED_COLOR 60 | else 61 | 'yellow' 62 | end 63 | end 64 | 65 | def emote(status) 66 | case status 67 | when 'failed' 68 | '(failed)' 69 | when 'changed' 70 | '(successful)' 71 | when 'unchanged' 72 | '(continue)' 73 | end 74 | end 75 | 76 | def process 77 | # Disabled check here to ensure it is checked for every report 78 | disabled = File.exists?(DISABLED_FILE) 79 | 80 | if (HIPCHAT_STATUSES.include?(self.status) || HIPCHAT_STATUSES.include?('all')) && !disabled 81 | Puppet.debug "Sending status for #{self.host} to Hipchat channel #{HIPCHAT_ROOM}" 82 | msg = "Puppet run for #{self.host} #{emote(self.status)} #{self.status} at #{Time.now.asctime} on #{self.configuration_version} in #{self.environment}" 83 | if HIPCHAT_PUPPETBOARD 84 | msg << ": #{HIPCHAT_PUPPETBOARD}/report/#{self.host}/#{self.configuration_version}" 85 | elsif HIPCHAT_DASHBOARD 86 | msg << ": #{HIPCHAT_DASHBOARD}/nodes/#{self.host}/view" 87 | end 88 | 89 | if HIPCHAT_STATUSES.include?('testing') 90 | # Acceptance tests because we cannot test the hipchat gem directly 91 | File.open('/tmp/hipchat-notified.txt', 'w') {|f| f.write(msg) } 92 | else 93 | client = HipChat::Client.new(HIPCHAT_API, :http_proxy => HIPCHAT_PROXY, :api_version => HIPCHAT_API_VERSION, :server_url => HIPCHAT_SERVER) 94 | client[HIPCHAT_ROOM].send('Puppet', msg, :notify => HIPCHAT_NOTIFY, :color => color(self.status), :message_format => 'text') 95 | end 96 | end 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Class: puppet_hipchat 2 | # 3 | # Send Puppet report information to HipChat 4 | # 5 | class puppet_hipchat ( 6 | $api_key, 7 | $room, 8 | $server = 'https://api.hipchat.com', 9 | $notify_color = 'red', 10 | $notify_room = false, 11 | $statuses = [ 'failed' ], 12 | $config_file = "${puppet_hipchat::params::puppetconf_path}/hipchat.yaml", 13 | $package_name = $puppet_hipchat::params::package_name, 14 | $install_hc_gem = $puppet_hipchat::params::install_hc_gem, 15 | $provider = $puppet_hipchat::params::provider, 16 | $owner = $puppet_hipchat::params::owner, 17 | $group = $puppet_hipchat::params::group, 18 | $puppetboard = $puppet_hipchat::params::puppetboard, 19 | $dashboard = $puppet_hipchat::params::dashboard, 20 | $api_version = $puppet_hipchat::params::api_version, 21 | $proxy = $puppet_hipchat::params::proxy, 22 | ) inherits puppet_hipchat::params { 23 | 24 | file { $config_file: 25 | ensure => file, 26 | owner => $owner, 27 | group => $group, 28 | mode => '0440', 29 | content => template('puppet_hipchat/hipchat.yaml.erb'), 30 | } 31 | 32 | if $install_hc_gem { 33 | package { $package_name: 34 | ensure => installed, 35 | provider => $provider, 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /manifests/params.pp: -------------------------------------------------------------------------------- 1 | # Class: puppet_hipchat::params 2 | # 3 | # Parameterize for Puppet platform. 4 | # 5 | class puppet_hipchat::params { 6 | 7 | $package_name = 'hipchat' 8 | $puppetboard = undef 9 | $dashboard = undef 10 | $api_version = 'v1' 11 | $proxy = undef 12 | 13 | if str2bool($::is_pe) { 14 | $install_hc_gem = true 15 | $puppetconf_path = '/etc/puppetlabs/puppet' 16 | $provider = 'pe_gem' 17 | $owner = 'pe-puppet' 18 | $group = 'pe-puppet' 19 | } elsif ($::puppetversion) and (versioncmp('4.0.0', $::puppetversion) < 1) { 20 | $puppetconf_path = '/etc/puppetlabs/puppet' 21 | $install_hc_gem = false 22 | $owner = 'puppet' 23 | $group = 'puppet' 24 | } else { 25 | $install_hc_gem = true 26 | $puppetconf_path = '/etc/puppet' 27 | $provider = 'gem' 28 | $owner = 'puppet' 29 | $group = 'puppet' 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jamtur01-hipchat", 3 | "version": "999.999.999", 4 | "author": "James Turnbull ", 5 | "license": "Apache-2.0", 6 | "summary": "A Puppet report handler for sending notifications of failed runs to HipChat", 7 | "source": "https://github.com/jamtur01/puppet-hipchat", 8 | "project_page": "https://github.com/jamtur01/puppet-hipchat", 9 | "issues_url": "https://github.com/jamtur01/puppet-hipchat/issues", 10 | "tags": ["hipchat", "notifications", "report"], 11 | "operatingsystem_support": [ 12 | { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7" ] }, 13 | { "operatingsystem": "Debian", "operatingsystemrelease": [ "7", "8" ] }, 14 | { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7" ] }, 15 | { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "12.04", "14.04", "16.04" ] } 16 | ], 17 | "dependencies": [ 18 | { "name": "puppetlabs/stdlib", "version_requirement": ">=3.2.0 <5.0.0" } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /spec/acceptance/hipchat_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_acceptance' 2 | 3 | describe 'puppet-hipchat' do 4 | context 'configure and send hipchat notification' do 5 | it 'should work with no errors' do 6 | # Because of puppetserver_gem not always resolving due to puppetserver 7 | # install cleanup, we will install the prerequisites first 8 | version = ENV['PUPPETSERVER_VERSION'] || 'present' 9 | pp = <<-EOS 10 | class { 'puppetserver::repository': } -> 11 | class { 'puppetserver': 12 | version => #{version}, 13 | config => { 14 | 'java_args' => { 15 | 'xms' => '256m', 16 | 'xmx' => '256m', 17 | 'maxpermsize' => '512m', 18 | }, 19 | }, 20 | } 21 | host { 'puppet': 22 | ip => '127.0.0.1', 23 | } 24 | EOS 25 | apply_manifest(pp, :catch_failures => true) 26 | 27 | # Now run the module 28 | pp = <<-EOS 29 | service { 'puppetserver': 30 | ensure => running 31 | } 32 | ini_setting {'report': 33 | ensure => present, 34 | path => '/etc/puppetlabs/puppet/puppet.conf', 35 | section => 'master', 36 | setting => 'report', 37 | value => 'true', 38 | notify => Service['puppetserver'], 39 | } 40 | ini_setting {'reports': 41 | ensure => present, 42 | path => '/etc/puppetlabs/puppet/puppet.conf', 43 | section => 'master', 44 | setting => 'reports', 45 | value => 'hipchat', 46 | notify => Service['puppetserver'], 47 | } 48 | class {'::puppet_hipchat': 49 | api_key => 'mykey', 50 | room => 'myroom', 51 | statuses => ['all', 'testing'], 52 | install_hc_gem => true, 53 | provider => 'puppetserver_gem', 54 | notify => Service['puppetserver'], 55 | } 56 | EOS 57 | 58 | apply_manifest(pp, :catch_failures => true) 59 | 60 | # run the agent, this will cause the reporting handler generate a tmp file 61 | # to show it executed properly 62 | agent = only_host_with_role(hosts, 'agent') 63 | expect(run_agent_on(agent).exit_code).to be_zero 64 | 65 | # validate idempotence 66 | expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero 67 | end 68 | 69 | describe file('/tmp/hipchat-notified.txt') do 70 | it { should be_file } 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-6-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-65-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: el-6-x86_64 7 | box: puppetlabs/centos-6.6-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-7-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-70-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: el-7-x86_64 7 | box: puppetlabs/centos-7.0-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-7-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | debian-78-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: debian-7-amd64 7 | box: puppetlabs/debian-7.8-64-nocm 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-8-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | debian-8-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: debian-8-amd64 7 | box: debian/jessie64 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/centos-6.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-6-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: el-6-x86_64 7 | hypervisor: docker 8 | image: centos:6 9 | docker_preserve_image: true 10 | docker_image_commands: 11 | - 'yum install -y which' 12 | CONFIG: 13 | type: aio 14 | log_level: debug 15 | trace_limit: 200 16 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/centos-7.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-7-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: el-7-x86_64 7 | hypervisor: docker 8 | image: centos:7 9 | docker_preserve_image: true 10 | docker_cmd: '["/usr/sbin/init"]' 11 | docker_image_commands: 12 | - 'yum install -y which' 13 | CONFIG: 14 | type: aio 15 | log_level: debug 16 | trace_limit: 200 17 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/debian-7.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | debian-7-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: debian-7-amd64 7 | hypervisor: docker 8 | image: debian:7 9 | docker_preserve_image: true 10 | docker_cmd: '["/sbin/init"]' 11 | docker_image_commands: 12 | - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' 13 | CONFIG: 14 | type: aio 15 | log_level: debug 16 | trace_limit: 200 17 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/debian-8.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | debian-8-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: debian-8-amd64 7 | hypervisor: docker 8 | image: debian:8 9 | docker_preserve_image: true 10 | docker_cmd: '["/sbin/init"]' 11 | docker_image_commands: 12 | - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' 13 | CONFIG: 14 | type: aio 15 | log_level: debug 16 | trace_limit: 200 17 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/ubuntu-12.04.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-1204-x64: 3 | roles: 4 | - master 5 | - agent 6 | # default_apply_opts: 7 | # order: random 8 | # strict_variables: 9 | platform: ubuntu-12.04-amd64 10 | hypervisor : docker 11 | image: ubuntu:12.04 12 | docker_preserve_image: true 13 | docker_cmd: '["/sbin/init"]' 14 | docker_image_commands: 15 | - 'apt-get install -y net-tools wget' 16 | - 'locale-gen en_US.UTF-8' 17 | - 'ln -s /opt/puppetlabs/bin/puppet /usr/local/bin/puppet' 18 | CONFIG: 19 | type: aio 20 | log_level: debug 21 | trace_limit: 200 22 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/ubuntu-14.04.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-1404-x64: 3 | roles: 4 | - master 5 | - agent 6 | default_apply_opts: 7 | order: random 8 | strict_variables: 9 | platform: ubuntu-14.04-amd64 10 | hypervisor : docker 11 | image: ubuntu:14.04 12 | docker_preserve_image: true 13 | docker_cmd: '["/sbin/init"]' 14 | docker_image_commands: 15 | - 'rm /usr/sbin/policy-rc.d' 16 | - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' 17 | - 'apt-get install -y net-tools wget' 18 | - 'locale-gen en_US.UTF-8' 19 | CONFIG: 20 | type: aio 21 | log_level: debug 22 | trace_limit: 200 23 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/docker/ubuntu-16.04.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-1604-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: ubuntu-16.04-amd64 7 | hypervisor: docker 8 | image: ubuntu:16.04 9 | docker_preserve_image: true 10 | docker_cmd: '["/sbin/init"]' 11 | docker_image_commands: 12 | - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' 13 | CONFIG: 14 | type: aio 15 | log_level: debug 16 | trace_limit: 200 17 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-12.04-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-12.04-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: ubuntu-12.04-amd64 7 | box: ubuntu/precise64 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-14.04-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-14.04-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: ubuntu-14.04-amd64 7 | box: ubuntu/trusty64 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-16.04-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-16.04-x64: 3 | roles: 4 | - master 5 | - agent 6 | platform: ubuntu-16.04-amd64 7 | box: boxcutter/ubuntu1604 8 | hypervisor: vagrant 9 | CONFIG: 10 | type: aio 11 | log_level: debug 12 | trace_limit: 200 13 | -------------------------------------------------------------------------------- /spec/classes/puppet_init_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'puppet_hipchat', :type => :class do 4 | let(:facts) { { :is_pe => false } } 5 | 6 | describe "default" do 7 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :server => 'myserver' } } 8 | it { should contain_package('hipchat').with(:provider => 'gem') } 9 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_api: mykey/) } 10 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_room: myroom/) } 11 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_server: myserver/) } 12 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_api_version: v1\n/) } 13 | it { should contain_file('/etc/puppet/hipchat.yaml').without(:content => /:hipchat_proxy:/) } 14 | it { should contain_file('/etc/puppet/hipchat.yaml').without(:content => /:hipchat_puppetboard:/) } 15 | it { should contain_file('/etc/puppet/hipchat.yaml').without(:content => /:hipchat_dashboard:/) } 16 | end 17 | 18 | describe "use api version 2" do 19 | let(:params) {{ :api_key => 'mykey', :room => 'myroom', :server => 'myserver', :api_version => 'v2' }} 20 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_api_version: v2/) } 21 | end 22 | 23 | describe "specify file location" do 24 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :config_file => '/tmp/foo' } } 25 | it { should contain_file('/tmp/foo') } 26 | end 27 | 28 | describe 'no hipchat gem' do 29 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :install_hc_gem => false } } 30 | it { should_not contain_package('hipchat') } 31 | end 32 | 33 | describe 'on pe' do 34 | let(:facts) { { :is_pe => true } } 35 | let(:params) { { :api_key => 'mykey', :room => 'myroom' } } 36 | it { should contain_package('hipchat').with(:provider => 'pe_gem') } 37 | it { should contain_file('/etc/puppetlabs/puppet/hipchat.yaml') } 38 | end 39 | 40 | describe 'on puppet 4' do 41 | let(:facts) { { :puppetversion => '4.0.0' } } 42 | let(:params) { { :api_key => 'mykey', :room => 'myroom' } } 43 | it { should_not contain_package('hipchat') } 44 | it { should contain_file('/etc/puppetlabs/puppet/hipchat.yaml') } 45 | end 46 | 47 | describe 'with proxy' do 48 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :server => 'myserver', :proxy => 'myproxy' } } 49 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_proxy: myproxy\n/) } 50 | end 51 | 52 | describe 'with puppetboard' do 53 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :server => 'myserver', :puppetboard => 'mypuppetboard' } } 54 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_puppetboard: mypuppetboard\n/) } 55 | end 56 | 57 | describe 'with dashboard' do 58 | let(:params) { { :api_key => 'mykey', :room => 'myroom', :server => 'myserver', :dashboard => 'mydashboard' } } 59 | it { should contain_file('/etc/puppet/hipchat.yaml').with(:content => /:hipchat_dashboard: mydashboard\n/) } 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/module_spec_helper' 3 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | require 'beaker-rspec/spec_helper' 2 | require 'beaker-rspec/helpers/serverspec' 3 | 4 | version = ENV['PUPPET_VERSION'] || '1.5.2' 5 | install_puppet_agent_on(hosts, {:puppet_agent_version => version}) 6 | 7 | RSpec.configure do |c| 8 | proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 9 | fixture_modules = File.join(proj_root, 'spec', 'fixtures', 'modules') 10 | 11 | c.formatter = :documentation 12 | 13 | # Configure all nodes in nodeset 14 | c.before :suite do 15 | path = File.expand_path(File.dirname(__FILE__) + '/../').split('/') 16 | 17 | # Install module 18 | puppet_module_install(source: proj_root, module_name: 'puppet_hipchat') 19 | 20 | # Install Dependencies 21 | hosts.each do |host| 22 | on host, puppet('module', 'install', 'puppetlabs-stdlib') 23 | 24 | # needed to test reporting 25 | on host, puppet('module', 'install', 'camptocamp-puppetserver') 26 | on host, puppet('module', 'install', 'puppetlabs-inifile') 27 | on host, puppet('module', 'install', 'puppetlabs-puppetserver_gem') 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /templates/hipchat.yaml.erb: -------------------------------------------------------------------------------- 1 | --- 2 | :hipchat_api: <%= @api_key %> 3 | :hipchat_server: <%= @server %> 4 | :hipchat_room: <%= @room %> 5 | :hipchat_notify_color: <%= @notify_color %> 6 | :hipchat_notify: <%= @notify_room %> 7 | :hipchat_api_version: <%= @api_version %> 8 | :hipchat_statuses: 9 | <% @statuses.each do |status| -%> 10 | - <%= status %> 11 | <% end -%> 12 | <% if @puppetboard -%> 13 | :hipchat_puppetboard: <%= @puppetboard %> 14 | <% end -%> 15 | <% if @dashboard -%> 16 | :hipchat_dashboard: <%= @dashboard %> 17 | <% end -%> 18 | <% if @proxy -%> 19 | :hipchat_proxy: <%= @proxy %> 20 | <% end -%> 21 | --------------------------------------------------------------------------------