From 442398a294e32bcd0bb140a46c97513e890fa5b1 Mon Sep 17 00:00:00 2001 From: Jason Guiditta Date: Wed, 2 Dec 2015 09:25:18 -0500 Subject: [PATCH] Automatic update This module update commit was generated by Bade. For more info please check https://github.com/paramite/bade This commit is setting modules to following state: uchiwa - initial commit: e3dc4fc3d5291d08a23f16843c673932adf450d5 Change-Id: Ibf43018e12ae3873206e223ea19deaeba68aba48 --- Puppetfile | 4 + uchiwa/.fixtures.yml | 6 + uchiwa/.gitignore | 6 + uchiwa/.rspec | 2 + uchiwa/.travis.yml | 44 ++++ uchiwa/CONTRIBUTORS | 3 + uchiwa/Gemfile | 30 +++ uchiwa/Gemfile.lock | 193 +++++++++++++++++ uchiwa/Guardfile | 5 + uchiwa/LICENSE | 202 ++++++++++++++++++ uchiwa/README.markdown | 94 ++++++++ uchiwa/Rakefile | 18 ++ uchiwa/manifests/config.pp | 14 ++ uchiwa/manifests/init.pp | 140 ++++++++++++ uchiwa/manifests/install.pp | 47 ++++ uchiwa/manifests/params.pp | 48 +++++ uchiwa/manifests/repo/apt.pp | 45 ++++ uchiwa/manifests/repo/yum.pp | 31 +++ uchiwa/manifests/service.pp | 16 ++ uchiwa/metadata.json | 71 ++++++ uchiwa/spec/acceptance/class_spec.rb | 92 ++++++++ .../acceptance/nodesets/centos-64-x64.yml | 11 + uchiwa/spec/acceptance/nodesets/default.yml | 11 + .../nodesets/ubuntu-server-12042-x64.yml | 11 + uchiwa/spec/classes/uchiwa_spec.rb | 155 ++++++++++++++ uchiwa/spec/spec_helper.rb | 9 + uchiwa/spec/spec_helper_acceptance.rb | 57 +++++ uchiwa/templates/etc/sensu/uchiwa.json.erb | 25 +++ 28 files changed, 1390 insertions(+) create mode 100755 uchiwa/.fixtures.yml create mode 100755 uchiwa/.gitignore create mode 100755 uchiwa/.rspec create mode 100755 uchiwa/.travis.yml create mode 100755 uchiwa/CONTRIBUTORS create mode 100755 uchiwa/Gemfile create mode 100644 uchiwa/Gemfile.lock create mode 100755 uchiwa/Guardfile create mode 100755 uchiwa/LICENSE create mode 100755 uchiwa/README.markdown create mode 100755 uchiwa/Rakefile create mode 100755 uchiwa/manifests/config.pp create mode 100755 uchiwa/manifests/init.pp create mode 100755 uchiwa/manifests/install.pp create mode 100755 uchiwa/manifests/params.pp create mode 100755 uchiwa/manifests/repo/apt.pp create mode 100755 uchiwa/manifests/repo/yum.pp create mode 100755 uchiwa/manifests/service.pp create mode 100644 uchiwa/metadata.json create mode 100644 uchiwa/spec/acceptance/class_spec.rb create mode 100644 uchiwa/spec/acceptance/nodesets/centos-64-x64.yml create mode 100644 uchiwa/spec/acceptance/nodesets/default.yml create mode 100644 uchiwa/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 uchiwa/spec/classes/uchiwa_spec.rb create mode 100755 uchiwa/spec/spec_helper.rb create mode 100644 uchiwa/spec/spec_helper_acceptance.rb create mode 100644 uchiwa/templates/etc/sensu/uchiwa.json.erb diff --git a/Puppetfile b/Puppetfile index 280ff1f6b..3d19ac1ac 100644 --- a/Puppetfile +++ b/Puppetfile @@ -250,6 +250,10 @@ mod 'tuskar', :commit => '52120a9c64eb411c1ef51dccfc6f758f7142f6a5', :git => 'https://github.com/openstack/puppet-tuskar.git' +mod 'uchiwa', + :commit => 'e3dc4fc3d5291d08a23f16843c673932adf450d5', + :git => 'https://github.com/Yelp/puppet-uchiwa.git' + mod 'vcsrepo', :commit => '99e8b2e28ce9541202b8b2438a92ee8ac2b03d6a', :git => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git' diff --git a/uchiwa/.fixtures.yml b/uchiwa/.fixtures.yml new file mode 100755 index 000000000..bbb0975d7 --- /dev/null +++ b/uchiwa/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + apt: 'git://github.com/puppetlabs/puppetlabs-apt.git' + stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' + symlinks: + uchiwa: "#{source_dir}" diff --git a/uchiwa/.gitignore b/uchiwa/.gitignore new file mode 100755 index 000000000..5104b2209 --- /dev/null +++ b/uchiwa/.gitignore @@ -0,0 +1,6 @@ +.*.sw? +pkg +!spec/fixtures/uchiwa +spec/fixtures +.rspec_system +.vagrant diff --git a/uchiwa/.rspec b/uchiwa/.rspec new file mode 100755 index 000000000..8c18f1abd --- /dev/null +++ b/uchiwa/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/uchiwa/.travis.yml b/uchiwa/.travis.yml new file mode 100755 index 000000000..1fd700aa1 --- /dev/null +++ b/uchiwa/.travis.yml @@ -0,0 +1,44 @@ +language: ruby +bundler_args: --without development +rvm: + - 1.9.3 + - 2.0.0 + - 2.1.0 +before_install: + - rm Gemfile.lock || true + - gem update --system 2.1.11 + - gem --version +script: + - "rake lint" + - "rake syntax" + - "rake spec SPEC_OPTS='--format documentation'" +env: + - PUPPET_VERSION="~> 2.7.0" + - PUPPET_VERSION="~> 3.2.0" + - PUPPET_VERSION="~> 3.3.0" + - PUPPET_VERSION="~> 3.4.0" + - PUPPET_VERSION="~> 3.5.0" + - PUPPET_VERSION="~> 3.5.0" STRICT_VARIABLES=yes + - PUPPET_VERSION="~> 3.6.0" + - PUPPET_VERSION="~> 3.6.0" STRICT_VARIABLES=yes + - PUPPET_VERSION="~> 3.7.0" + - PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes + - PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 3.1.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.0.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.2.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.3.0" + - rvm: 2.1.0 + env: PUPPET_VERSION="~> 3.4.0" diff --git a/uchiwa/CONTRIBUTORS b/uchiwa/CONTRIBUTORS new file mode 100755 index 000000000..42961b74a --- /dev/null +++ b/uchiwa/CONTRIBUTORS @@ -0,0 +1,3 @@ +pauloconnor +bjwschaap +LarsFronius diff --git a/uchiwa/Gemfile b/uchiwa/Gemfile new file mode 100755 index 000000000..4609bd9b9 --- /dev/null +++ b/uchiwa/Gemfile @@ -0,0 +1,30 @@ +source 'https://rubygems.org' + +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', "~> 2.2.4",:require => false + gem 'pry', :require => false + gem 'simplecov', :require => false + gem 'vagrant-wrapper', :require => false +end + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby \ No newline at end of file diff --git a/uchiwa/Gemfile.lock b/uchiwa/Gemfile.lock new file mode 100644 index 000000000..52c660624 --- /dev/null +++ b/uchiwa/Gemfile.lock @@ -0,0 +1,193 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.2.8) + addressable (2.3.6) + archive-tar-minitar (0.5.2) + autoparse (0.3.3) + addressable (>= 2.3.1) + extlib (>= 0.9.15) + multi_json (>= 1.0.0) + aws-sdk (1.42.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + beaker (1.17.6) + aws-sdk (= 1.42.0) + blimpy (~> 0.6) + docker-api + fission (~> 0.4) + google-api-client (~> 0.7.1) + hocon (~> 0.0.4) + inifile (~> 2.0) + json (~> 1.8) + mime-types (~> 1.25) + net-scp (~> 1.1) + net-ssh (~> 2.6) + nokogiri (~> 1.5.10) + rbvmomi (= 1.8.1) + unf (~> 0.1) + beaker-rspec (2.2.6) + beaker (~> 1.10) + rspec + serverspec (~> 1.0) + specinfra (~> 1.0) + blimpy (0.6.7) + fog + minitar + thor + builder (3.2.2) + coderay (1.1.0) + diff-lcs (1.2.5) + docile (1.1.5) + docker-api (1.13.2) + archive-tar-minitar + excon (>= 0.38.0) + json + excon (0.39.5) + extlib (0.9.16) + facter (2.1.0) + CFPropertyList (~> 2.2.6) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.23.0) + fog-brightbox + fog-core (~> 1.23) + fog-json + fog-softlayer + ipaddress (~> 0.5) + nokogiri (~> 1.5, >= 1.5.11) + fog-brightbox (0.4.1) + fog-core (~> 1.22) + fog-json + inflecto + fog-core (1.24.0) + builder + excon (~> 0.38) + formatador (~> 0.2) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + fog-json (1.0.0) + multi_json (~> 1.0) + fog-softlayer (0.3.15) + fog-core + fog-json + formatador (0.2.5) + google-api-client (0.7.1) + addressable (>= 2.3.2) + autoparse (>= 0.3.3) + extlib (>= 0.9.15) + faraday (>= 0.9.0) + jwt (>= 0.1.5) + launchy (>= 2.1.1) + multi_json (>= 1.0.0) + retriable (>= 1.4) + signet (>= 0.5.0) + uuidtools (>= 2.1.0) + hiera (1.3.4) + json_pure + highline (1.6.21) + hocon (0.0.4) + inflecto (0.0.2) + inifile (2.0.2) + ipaddress (0.8.0) + json (1.8.1) + json_pure (1.8.1) + jwt (1.0.0) + launchy (2.4.2) + addressable (~> 2.3) + metaclass (0.0.4) + method_source (0.8.2) + mime-types (1.25.1) + minitar (0.5.4) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.10.1) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) + nokogiri (1.5.11) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + puppet (3.6.2) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + rgen (~> 0.6.5) + puppet-lint (0.3.2) + puppet-syntax (1.3.0) + rake + puppetlabs_spec_helper (0.8.0) + mocha + puppet-lint + puppet-syntax + rake + rspec + rspec-puppet + rake (10.3.2) + rbvmomi (1.8.1) + builder + nokogiri (>= 1.4.1) + trollop + retriable (1.4.1) + rgen (0.6.6) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.1) + rspec-expectations (2.99.2) + diff-lcs (>= 1.1.3, < 2.0) + rspec-its (1.0.1) + rspec-core (>= 2.99.0.beta1) + rspec-expectations (>= 2.99.0.beta1) + rspec-mocks (2.99.2) + rspec-puppet (1.0.1) + rspec + serverspec (1.14.0) + highline + net-ssh + rspec (~> 2.99) + rspec-its + specinfra (~> 1.25) + signet (0.5.1) + addressable (>= 2.2.3) + faraday (>= 0.9.0.rc5) + jwt (>= 0.1.5) + multi_json (>= 1.0.0) + simplecov (0.9.0) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + slop (3.6.0) + specinfra (1.25.8) + thor (0.19.1) + trollop (2.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.6) + uuidtools (2.1.5) + vagrant-wrapper (1.2.1.1) + +PLATFORMS + ruby + +DEPENDENCIES + beaker + beaker-rspec (~> 2.2.4) + facter + pry + puppet + puppet-lint + puppetlabs_spec_helper + rake + rspec-puppet + serverspec + simplecov + vagrant-wrapper diff --git a/uchiwa/Guardfile b/uchiwa/Guardfile new file mode 100755 index 000000000..fd50602a0 --- /dev/null +++ b/uchiwa/Guardfile @@ -0,0 +1,5 @@ +notification :off + +guard 'rake', :task => 'test' do + watch(%r{^manifests\/(.+)\.pp$}) +end diff --git a/uchiwa/LICENSE b/uchiwa/LICENSE new file mode 100755 index 000000000..9f710553e --- /dev/null +++ b/uchiwa/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +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. + diff --git a/uchiwa/README.markdown b/uchiwa/README.markdown new file mode 100755 index 000000000..0eb688e96 --- /dev/null +++ b/uchiwa/README.markdown @@ -0,0 +1,94 @@ +# Uchiwa-Puppet + +Tested with Travis CI + +[![Build Status](https://travis-ci.org/Yelp/puppet-uchiwa.svg?branch=master)](https://travis-ci.org/Yelp/puppet-uchiwa) + +## Upgrade Note + +Versions greater than 0.3.0 are incompatible with previous versions of the Yelp-Uchiwa module. + +## Installation + + $ puppet module install yelp-uchiwa + +## Prerequisites +- One or more working Sensu installations + +### Dependencies +- puppetlabs/apt +- puppetlabs/stdlib + +See `Modulefile` for details. + +## Examples + +### Simple Setup + +By default the puppet module will connect to a single Sensu API endpoint on +localhost: + +```puppet +node 'uchiwa-server.foo.com' { + include ::uchiwa +} +``` + +API definitions will default to the following values: + + name => 'sensu' + host => '127.0.0.1' + ssl => false + insecure => false + port => 4567 + user => 'sensu' + pass => 'sensu' + path => '' + timeout => 5 + +### Simple Server Without the Repo + +The module itself sets up the Sensu repo in order to download Uchiwa. Often this +is also done by the Sensu puppet module too. To get around this duplication you +can ask the Uchiwa module not to manage the repo: + +```puppet +class { '::uchiwa': + install_repo => false, +} +``` + +### Advanced Example Using Multiple APIs + +This is an example of how to setup Uchiwa connecting +to two different API endpoints. In this example there is +one endpoint using mostly default parameters, and then +a second endpoint using all the possible options: + +```puppet +node 'uchiwa-server.foo.com' { + + $uchiwa_api_config = [ + { + host => '10.56.5.8', + }, + { + host => '10.16.1.25', + ssl => true, + insecure => true, + port => 7654, + user => 'sensu', + pass => 'saBEnX8PQoyz2LG', + path => '/sensu', + timeout => 5 + } + ] + class { 'uchiwa': + sensu_api_endpoints => $uchiwa_api_config, + } +} +``` + +## License + +See LICENSE file. diff --git a/uchiwa/Rakefile b/uchiwa/Rakefile new file mode 100755 index 000000000..2ad6ca615 --- /dev/null +++ b/uchiwa/Rakefile @@ -0,0 +1,18 @@ +require 'rubygems' +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +exclude_paths = [ + "pkg/**/*", + "vendor/**/*", + "spec/**/*", +] + +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.send("disable_autoloader_layout") +PuppetLint.configuration.send("disable_quoted_booleans") +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths \ No newline at end of file diff --git a/uchiwa/manifests/config.pp b/uchiwa/manifests/config.pp new file mode 100755 index 000000000..16ad61dad --- /dev/null +++ b/uchiwa/manifests/config.pp @@ -0,0 +1,14 @@ +# == Class uchiwa::config +# +# This class is called from uchiwa +# +class uchiwa::config inherits uchiwa { + + file { '/etc/sensu/uchiwa.json': + ensure => file, + content => template('uchiwa/etc/sensu/uchiwa.json.erb'), + owner => uchiwa, + group => uchiwa, + mode => '0440', + } +} diff --git a/uchiwa/manifests/init.pp b/uchiwa/manifests/init.pp new file mode 100755 index 000000000..f5bc008dd --- /dev/null +++ b/uchiwa/manifests/init.pp @@ -0,0 +1,140 @@ +# == Class: uchiwa +# +# Base Uchiwa class +# +# === Parameters +# +# [*sample_parameter*] +# Explanation of what this parameter affects and what it defaults to. +# +# [*package_name*] +# String +# Default: uchiwa +# Name of the package to install +# +# [*service_name*] +# String +# Default: uchiwa +# Name of the service to start +# +# [*version*] +# String +# Default: latest +# Which version of the package to install +# +# [*install_repo*] +# Boolean +# Default: true +# Should we install the repo? +# +# [*repo*] +# String +# Default: main +# Which repo should we read from, main or unstable? +# +# [*repo_source*] +# String +# Default: undef +# What's the url for the repo we should install? +# +# [*repo_key_id*] +# String +# Default: 7580C77F +# The repo key for Apt +# +# [*repo_key_source*] +# String +# Default: http://repos.sensuapp.org/apt/pubkey.gpg +# GPG key for the repo we're installing +# +# [*manage_services*] +# Boolean +# Default: true +# Should we start the service? +# +# [*manage_user*] +# Boolean +# Default: true +# Should we add the Uchiwa user? +# +# [*host*] +# String +# Default: 0.0.0.0 +# What IP should we bind to? +# +# [*port*] +# Integer +# Default: 3000 +# What port should we run on? +# +# [*user*] +# String +# Default: '' +# The username of the Uchiwa dashboard. Leave empty for none. +# +# [*pass*] +# String +# Default: '' +# The password of the Uchiwa dashboard. Leave empty for none. +# +# [*refresh*] +# String +# Default: 5 +# Determines the interval to pull the Sensu API, in seconds +# +# [*sensu_api_endpoints*] +# Array of hashes +# Default: [{ +# name => 'sensu', +# ssl => false, +# port => 4567, +# user => 'sensu', +# pass => 'sensu', +# path => '', +# timeout => 5, +# }] +# An array of API endpoints to connect uchiwa to one or multiple sensu servers. +# +class uchiwa ( + $package_name = $uchiwa::params::package_name, + $service_name = $uchiwa::params::service_name, + $version = $uchiwa::params::version, + $install_repo = $uchiwa::params::install_repo, + $repo = $uchiwa::params::repo, + $repo_source = $uchiwa::params::repo_source, + $repo_key_id = $uchiwa::params::repo_key_id, + $repo_key_source = $uchiwa::params::repo_key_source, + $manage_services = $uchiwa::params::manage_services, + $manage_user = $uchiwa::params::manage_user, + $host = $uchiwa::params::host, + $port = $uchiwa::params::port, + $user = $uchiwa::params::user, + $pass = $uchiwa::params::pass, + $refresh = $uchiwa::params::refresh, + $sensu_api_endpoints = $uchiwa::params::sensu_api_endpoints, +) inherits uchiwa::params { + + # validate parameters here + validate_bool($install_repo) + validate_bool($manage_services) + validate_bool($manage_user) + validate_string($package_name) + validate_string($service_name) + validate_string($version) + validate_string($repo) + validate_string($repo_source) + validate_string($repo_key_id) + validate_string($repo_key_source) + validate_string($host) + validate_integer($port) + validate_string($user) + validate_string($pass) + validate_integer($refresh) + validate_array($sensu_api_endpoints) + + anchor { 'uchiwa::begin': } -> + class { 'uchiwa::install': } -> + class { 'uchiwa::config': } ~> + class { 'uchiwa::service': } -> + anchor { 'uchiwa::end': } +} diff --git a/uchiwa/manifests/install.pp b/uchiwa/manifests/install.pp new file mode 100755 index 000000000..982116075 --- /dev/null +++ b/uchiwa/manifests/install.pp @@ -0,0 +1,47 @@ +# == Class uchiwa::install +# +class uchiwa::install { + case $::osfamily { + 'Debian': { + class { 'uchiwa::repo::apt': } + if ($uchiwa::install_repo) { + $repo_require = Apt::Source['sensu'] + } else { + $repo_require = undef + } + } + + 'RedHat': { + class { 'uchiwa::repo::yum': } + if ($uchiwa::install_repo) { + $repo_require = Yumrepo['sensu'] + } else { + $repo_require = undef + } + } + + default: { alert("${::osfamily} not supported yet") } + } + + if $uchiwa::manage_user { + user { 'uchiwa': + ensure => 'present', + system => true, + home => '/opt/uchiwa', + shell => '/bin/false', + comment => 'Uchiwa Monitoring Dashboard', + } + + group { 'uchiwa': + ensure => 'present', + system => true, + } + } + + package { $uchiwa::package_name: + ensure => $uchiwa::version, + require => $repo_require, + notify => Service['uchiwa'], + } + +} diff --git a/uchiwa/manifests/params.pp b/uchiwa/manifests/params.pp new file mode 100755 index 000000000..1683e081d --- /dev/null +++ b/uchiwa/manifests/params.pp @@ -0,0 +1,48 @@ +# == Class uchiwa::params +# +# This class is meant to be called from uchiwa +# It sets variables according to platform +# +class uchiwa::params { + case $::osfamily { + 'Debian': { + $package_name = 'uchiwa' + $service_name = 'uchiwa' + } + 'RedHat', 'Amazon': { + $package_name = 'uchiwa' + $service_name = 'uchiwa' + } + default: { + fail("${::operatingsystem} not supported") + } + } + + $version = 'latest' + $install_repo = true + $repo = 'main' + $repo_source = undef + $repo_key_id = '8911D8FF37778F24B4E726A218609E3D7580C77F' + $repo_key_source = 'http://repos.sensuapp.org/apt/pubkey.gpg' + $manage_services = true + $manage_user = true + + $sensu_api_endpoints = [ + { + name => 'sensu', + host => '127.0.0.1', + ssl => false, + insecure => false, + port => 4567, + user => 'sensu', + pass => 'sensu', + path => '', + timeout => 5, + } + ] + $host = '0.0.0.0' + $port = 3000 + $user = '' + $pass = '' + $refresh = '5' +} diff --git a/uchiwa/manifests/repo/apt.pp b/uchiwa/manifests/repo/apt.pp new file mode 100755 index 000000000..eedd082df --- /dev/null +++ b/uchiwa/manifests/repo/apt.pp @@ -0,0 +1,45 @@ +# = Class: uchiwa::repo::apt +# +# Adds the uchiwa repo to Apt +# +class uchiwa::repo::apt { + + if $caller_module_name != $module_name { + fail("Use of private class ${name} by ${caller_module_name}") + } + + if $uchiwa::install_repo { + if defined(apt::source) { + + $ensure = $uchiwa::install_repo ? { + true => 'present', + default => 'absent' + } + + if $uchiwa::repo_source { + $url = $uchiwa::repo_source + } else { + $url = 'http://repos.sensuapp.org/apt' + } + + apt::source { 'sensu': + ensure => $ensure, + before => Package['uchiwa'], + include => { + 'src' => false, + 'deb' => true, + }, + key => { + 'id' => $uchiwa::repo_key_id, + 'source' => $uchiwa::repo_key_source, + }, + location => $url, + release => 'sensu', + repos => $uchiwa::repo, + } + + } else { + fail('This class requires puppet-apt module') + } + } +} diff --git a/uchiwa/manifests/repo/yum.pp b/uchiwa/manifests/repo/yum.pp new file mode 100755 index 000000000..54e2e5b86 --- /dev/null +++ b/uchiwa/manifests/repo/yum.pp @@ -0,0 +1,31 @@ +# = Class: uchiwa::repo::yum +# +# Adds the uchiwa YUM repo support +# +class uchiwa::repo::yum { + + if $caller_module_name != $module_name { + fail("Use of private class ${name} by ${caller_module_name}") + } + + if $uchiwa::install_repo { + if $uchiwa::repo_source { + $url = $uchiwa::repo_source + } else { + $url = $uchiwa::repo ? { + 'unstable' => "http://repos.sensuapp.org/yum-unstable/el/${::operatingsystemmajrelease}/\$basearch/", + default => "http://repos.sensuapp.org/yum/el/${::operatingsystemmajrelease}/\$basearch/" + } + } + + yumrepo { 'sensu': + enabled => 1, + baseurl => $url, + gpgcheck => 0, + name => 'sensu', + descr => 'sensuapp.org uchiwa repo', + before => Package['uchiwa'], + } + } + +} \ No newline at end of file diff --git a/uchiwa/manifests/service.pp b/uchiwa/manifests/service.pp new file mode 100755 index 000000000..a54658cda --- /dev/null +++ b/uchiwa/manifests/service.pp @@ -0,0 +1,16 @@ +# == Class uchiwa::service +# +# This class is meant to be called from uchiwa +# It ensure the service is running +# +class uchiwa::service { + + if $uchiwa::manage_services == true { + service { $uchiwa::service_name: + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + } + } +} diff --git a/uchiwa/metadata.json b/uchiwa/metadata.json new file mode 100644 index 000000000..5fe005e71 --- /dev/null +++ b/uchiwa/metadata.json @@ -0,0 +1,71 @@ +{ + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + } + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": "3.x" + } + ], + "name": "yelp-uchiwa", + "version": "0.3.0", + "author": "yelp", + "summary": "Puppet module for installing Uchiwa", + "license": "Apache 2.0", + "source": "github.com/yelp/puppet-uchiwa", + "project_page": "https://github.com/yelp/puppet-uchiwa", + "issues_url": "https://github.com/yelp/puppet-uchiwa/issues", + "description": "Puppet module for installing Uchiwa", + "dependencies": [ + {"name":"puppetlabs/apt","version_requirement": ">=2.0.0 <3.0.0"}, + {"name":"puppetlabs/stdlib"} + ] +} diff --git a/uchiwa/spec/acceptance/class_spec.rb b/uchiwa/spec/acceptance/class_spec.rb new file mode 100644 index 000000000..8b6e6d8c5 --- /dev/null +++ b/uchiwa/spec/acceptance/class_spec.rb @@ -0,0 +1,92 @@ +require 'spec_helper_acceptance' + +describe 'sensu class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'uchiwa' do + context 'ensure => present' do + it 'should work with no errors' do + pp = <<-EOS + class { 'rabbitmq': + package_ensure => installed, + ssl => false, + delete_guest_user => true, + } + -> rabbitmq_vhost { 'sensu': } + -> rabbitmq_user { 'sensu': password => 'secret' } + -> rabbitmq_user_permissions { 'sensu@sensu': + configure_permission => '.*', + read_permission => '.*', + write_permission => '.*', + } + class { 'redis': } + class { 'sensu': + server => true, + api => true, + purge_config => true, + rabbitmq_password => 'secret', + rabbitmq_host => 'localhost', + } + + class { 'uchiwa': + install_repo => false, + sensu_api_endpoints => [{ + name => 'Main Server', + host => '127.0.0.1', + ssl => false, + insecure => false, + port => 4567, + user => 'sensu', + pass => 'secret', + path => '', + timeout => 5000 + }], + require => Class['sensu'], + } + EOS + + + # Run it twice and test for idempotency + expect(apply_manifest(pp, :catch_failures => true).exit_code) + expect(apply_manifest(pp, :catch_failures => true).exit_code) + end + it 'should start uchiwa' do + shell('curl localhost:3000/') do |curl| + expect(curl.stdout).to include '' + end + end + it 'should produce consistent uchiwa.json file' do + + uchiwa_json = "{\n\"sensu\": [\n {\n \"name\": \"Main Server\",\n \"host\": \"127.0.0.1\",\n \"ssl\": false,\n \"insecure\": false,\n \"port\": 4567,\n \"user\": \"sensu\",\n \"pass\": \"secret\",\n \"path\": \"\",\n \"timeout\": 5000\n }\n ],\n \"uchiwa\": {\n \"host\": \"0.0.0.0\",\n \"port\": 3000,\n \"user\": \"\",\n \"pass\": \"\",\n \"refresh\": 5\n }\n}\n" + + shell('cat /etc/sensu/uchiwa.json') do |cat| + expect(cat.stdout).to eq (uchiwa_json) + end + end + + describe file('/etc/sensu/uchiwa.json') do + it { should be_owned_by 'uchiwa' } + it { should be_grouped_into 'uchiwa' } + it { should be_mode 440 } + end + + it 'rerun puppet with default params' do + + pp = <<-EOS + + include ::uchiwa + + EOS + expect(apply_manifest(pp, :catch_failures => true).exit_code) + end + + it 'should produce a uchiwa.json file from defaults' do + + uchiwa_json = "{\n\"sensu\": [\n {\n \"name\": \"sensu\",\n \"host\": \"127.0.0.1\",\n \"ssl\": false,\n \"insecure\": false,\n \"port\": 4567,\n \"user\": \"sensu\",\n \"pass\": \"sensu\",\n \"path\": \"\",\n \"timeout\": 5000\n }\n ],\n \"uchiwa\": {\n \"host\": \"0.0.0.0\",\n \"port\": 3000,\n \"user\": \"\",\n \"pass\": \"\",\n \"refresh\": 5\n }\n}\n" + + shell('cat /etc/sensu/uchiwa.json') do |cat| + expect(cat.stdout).to eq (uchiwa_json) + end + end + end + end +end diff --git a/uchiwa/spec/acceptance/nodesets/centos-64-x64.yml b/uchiwa/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 000000000..fb933cdbe --- /dev/null +++ b/uchiwa/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box: centos-64-x64-vbox4210-nocm + box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor: vagrant +CONFIG: + log_level: verbose + type: foss diff --git a/uchiwa/spec/acceptance/nodesets/default.yml b/uchiwa/spec/acceptance/nodesets/default.yml new file mode 100644 index 000000000..901bb92fc --- /dev/null +++ b/uchiwa/spec/acceptance/nodesets/default.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box: ubuntu-server-12042-x64-vbox4210-nocm + box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor: vagrant +CONFIG: + log_level: verbose + type: foss diff --git a/uchiwa/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/uchiwa/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 000000000..901bb92fc --- /dev/null +++ b/uchiwa/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box: ubuntu-server-12042-x64-vbox4210-nocm + box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor: vagrant +CONFIG: + log_level: verbose + type: foss diff --git a/uchiwa/spec/classes/uchiwa_spec.rb b/uchiwa/spec/classes/uchiwa_spec.rb new file mode 100644 index 000000000..41608e7f8 --- /dev/null +++ b/uchiwa/spec/classes/uchiwa_spec.rb @@ -0,0 +1,155 @@ +require 'spec_helper' + +describe 'uchiwa' do + let(:facts) { + { + :osfamily => 'RedHat', + :concat_basedir => '/dne', + } + } + + it 'should compile' do should create_class('uchiwa') end + it { should contain_class('uchiwa::config')} + + context 'config file' do + it { should contain_file('/etc/sensu/uchiwa.json').with_ensure('file') } + it { should contain_file('/etc/sensu/uchiwa.json').with_content(/"host": "127.0.0.1"/) } + it { should contain_file('/etc/sensu/uchiwa.json').with_owner('uchiwa') } + it { should contain_file('/etc/sensu/uchiwa.json').with_group('uchiwa') } + it { should contain_file('/etc/sensu/uchiwa.json').with_mode('0440') } + end + + context 'package' do + context 'defaults' do + it { should create_class('uchiwa::repo::yum') } + it { should contain_package('uchiwa').with_ensure('latest') } + it { should contain_file('/etc/sensu/uchiwa.json') } + end + + context 'setting version' do + let(:params) { { + :version => '0.1.5', + } } + + it { should contain_package('uchiwa').with( + :ensure => '0.1.5' + ).that_notifies('Service[uchiwa]') } + end + + context 'repos' do + + context 'ubuntu' do + let(:facts) { + { + :osfamily => 'Debian', + :fqdn => 'testhost.domain.com', + :concat_basedir => '/dne' + } + } + + context 'with puppet-apt installed' do + let(:pre_condition) { [ 'define apt::source ($ensure, $location, $release, $repos, $include, $key) {}' ] } + + context 'default' do + it { should contain_apt__source('sensu').with( + :ensure => 'present', + :location => 'http://repos.sensuapp.org/apt', + :release => 'sensu', + :repos => 'main', + :include => { 'src' => false, 'deb' => true }, + :key => { 'id' => '8911D8FF37778F24B4E726A218609E3D7580C77F', 'source' => 'http://repos.sensuapp.org/apt/pubkey.gpg' }, + :before => 'Package[uchiwa]' + ) } + end + + context 'unstable repo' do + let(:params) { { :repo => 'unstable' } } + it { should contain_apt__source('sensu').with_repos('unstable') } + end + + context 'override repo url' do + let(:params) { { :repo_source => 'http://repo.mydomain.com/apt' } } + it { should contain_apt__source('sensu').with( :location => 'http://repo.mydomain.com/apt') } + + it { should_not contain_apt__key('sensu').with( + :key => '7580C77F', + :key_source => 'http://repo.mydomain.com/apt/pubkey.gpg' + ) } + end + + context 'override key ID and key source' do + let(:params) { { :repo_key_id => 'FFFFFFFF', :repo_key_source => 'http://repo.mydomina.com/apt/pubkey.gpg' } } + + it { should_not contain_apt__key('sensu').with( + :key => 'FFFFFFFF', + :key_source => 'http://repo.mydomain.com/apt/pubkey.gpg' + ) } + end + + context 'install_repo => false' do + let(:params) { { :install_repo => false, :repo => 'main' } } + + it { should_not contain_apt__source('sensu') } + + it { should_not contain_apt__key('sensu').with( + :key => '7580C77F', + :key_source => 'http://repos.sensuapp.org/apt/pubkey.gpg' + ) } + + it { should contain_package('uchiwa').with( + :require => nil + ) } + end + end + + context 'without puppet-apt installed' do + it { expect { should raise_error(Puppet::Error) } } + end + end + + context 'redhat' do + let(:facts) { { :osfamily => 'RedHat', :operatingsystemmajrelease => '6',:concat_basedir => '/dne', } } + + context 'default' do + it { should contain_yumrepo('sensu').with( + :enabled => 1, + :baseurl => 'http://repos.sensuapp.org/yum/el/6/$basearch/', + :gpgcheck => 0, + :before => 'Package[uchiwa]' + ) } + end + + context 'unstable repo' do + let(:params) { { :repo => 'unstable' } } + it { should contain_yumrepo('sensu').with(:baseurl => 'http://repos.sensuapp.org/yum-unstable/el/6/$basearch/' )} + end + + context 'override repo url' do + let(:params) { { :repo_source => 'http://repo.mydomain.com/yum' } } + it { should contain_yumrepo('sensu').with( :baseurl => 'http://repo.mydomain.com/yum') } + end + + context 'install_repo => false' do + let(:params) { { :install_repo => false } } + + it { should_not contain_yumrepo('sensu') } + + it { should contain_package('uchiwa').with( + :require => nil + ) } + end + end + end + + end + + context 'with sensu_api_endpoints' do + let(:params) {{ :sensu_api_endpoints => [ { 'name' => 'foo', 'host' => 'bar' } ] }} + it { + should contain_file('/etc/sensu/uchiwa.json') \ + .with_content(/"name": "foo"/) \ + .with_content(/"host": "bar"/) + } + end + +end diff --git a/uchiwa/spec/spec_helper.rb b/uchiwa/spec/spec_helper.rb new file mode 100755 index 000000000..c73968cbe --- /dev/null +++ b/uchiwa/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require "rubygems" +require "rspec-puppet" + +fixture_path = File.expand_path File.join(__FILE__, "..", "fixtures") + +RSpec.configure do |c| + c.manifest_dir = File.join(fixture_path, "manifests") + c.module_path = File.join(fixture_path, "modules") +end \ No newline at end of file diff --git a/uchiwa/spec/spec_helper_acceptance.rb b/uchiwa/spec/spec_helper_acceptance.rb new file mode 100644 index 000000000..6ab91397c --- /dev/null +++ b/uchiwa/spec/spec_helper_acceptance.rb @@ -0,0 +1,57 @@ +require 'beaker-rspec' + +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + if host.is_pe? + install_pe + else + install_puppet + on host, "mkdir -p #{host['distmoduledir']}" + end + end +end + +UNSUPPORTED_PLATFORMS = ['windows'] + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'uchiwa') + hosts.each do |host| + if fact('osfamily') == 'Debian' + # RubyGems missing on some Vagrant boxes + # Otherwise you'lll get a load of 'Provider gem is not functional on this host' + shell('apt-get install rubygems -y') + # TODO: puppetlabs-rabbitmq 4.1 doesn't support rabbitmq 3.4.0. + # Remove the following two lines after a new puppetlabs-rabbitmq release + # that contains PR #250 + shell('apt-get install erlang-nox -y') + shell('wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.5/rabbitmq-server_3.3.5-1_all.deb && sudo dpkg -i rabbitmq-server_3.3.5-1_all.deb') + end + if fact('osfamily') == 'RedHat' + # RedHat needs EPEL for RabbitMQ and Redis + shell('wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm && sudo rpm -Uvh epel-release-6*.rpm') + # TODO: puppetlabs-rabbitmq 4.1 doesn't support rabbitmq 3.4.0. + # Remove the following three lines after a new puppetlabs-rabbitmq release + # that contains PR #250 + shell('sed -i \'s/\(mirrorlist=http\)s/\1/\' /etc/yum.repos.d/epel.repo') + shell('yum install -y erlang') + shell('rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.5/rabbitmq-server-3.3.5-1.noarch.rpm') + end + shell('/bin/touch /etc/puppet/hiera.yaml') + shell('puppet module install puppetlabs-stdlib --version 3.2.0', { :acceptable_exit_codes => [0] }) + shell('puppet module install maestrodev/wget --version 1.4.5', { :acceptable_exit_codes => [0] }) + shell('puppet module install puppetlabs/apt --version 1.6.0', { :acceptable_exit_codes => [0] }) + shell('puppet module install puppetlabs-rabbitmq --version 4.1.0', { :acceptable_exit_codes => [0] }) + shell('puppet module install fsalum-redis --version 1.0.0', { :acceptable_exit_codes => [0] }) + shell('puppet module install sensu-sensu', { :acceptable_exit_codes => [0] }) + end + end +end diff --git a/uchiwa/templates/etc/sensu/uchiwa.json.erb b/uchiwa/templates/etc/sensu/uchiwa.json.erb new file mode 100644 index 000000000..771f4a5fd --- /dev/null +++ b/uchiwa/templates/etc/sensu/uchiwa.json.erb @@ -0,0 +1,25 @@ +{ +"sensu": [ + <%- default_endpoint = scope['uchiwa::params::sensu_api_endpoints'][0] -%> + <%- @sensu_api_endpoints.each_with_index do |endpoint, i| -%> + { + "name": "<%= endpoint['name'] || default_endpoint['name'] %>", + "host": "<%= endpoint['host'] || default_endpoint['host'] %>", + "ssl": <%= endpoint['ssl'] || default_endpoint['ssl'] %>, + "insecure": <%= endpoint['insecure'] || default_endpoint['insecure']%>, + "port": <%= endpoint['port'] || default_endpoint['port'] %>, + "user": "<%= endpoint['user'] || default_endpoint['user'] %>", + "pass": "<%= endpoint['pass'] || default_endpoint['pass'] %>", + "path": "<%= endpoint['path'] || default_endpoint['path'] %>", + "timeout": <%= endpoint['timeout'] || default_endpoint['timeout'] %> + }<%= ',' if i < (@sensu_api_endpoints.size - 1) %> + <%- end -%> + ], + "uchiwa": { + "host": "<%= @host %>", + "port": <%= @port %>, + "user": "<%= @user %>", + "pass": "<%= @pass %>", + "refresh": <%= @refresh %> + } +}