diff --git a/.rubocop.yml b/.rubocop.yml index 6c4088287..37a99905d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,6 +10,8 @@ AllCops: - 'opsworks_nodejs/**/*' - 'vagrant-test/**/*' - 'test/**/*' + - 'erlang/**/*' + - 'rabbitmq/**/*' - 'Rakefile' - 'fc_sandbox/**/*' diff --git a/.travis.yml b/.travis.yml index 5f242ee9b..d2ad54156 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,8 @@ rvm: - 1.9.3 script: - - find . -type f -name "*.rb" -exec ruby -c {} > /dev/null \; - - rake rubocop - - rake test - - rake spec - - rake foodcritic + - make cs + - make test after_success: - tar cfz easybib-cookbooks.tar.gz * --exclude=easybib-cookbooks.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..818af07bb --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +rake=bundle exec rake + +cs: + $(rake) rubocop + $(rake) foodcritic + +test: + find . -type f -name "*.rb" -exec ruby -c {} > /dev/null \; + $(rake) test + $(rake) spec diff --git a/VERSIONS.md b/VERSIONS.md index 1517cdc55..e8b296cb5 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,13 +1,15 @@ Package | External Version | Comment ------------ | ------------- | ------------- apt| [2.5.3](https://github.com/opscode-cookbooks/apt/tree/v2.5.3) | added apt::easybib, apt::mirror.rb, apt::ppa, apt::proxy, apt::repair.rb, apt::updater.rb -build-essential| [2.0.2](https://github.com/opscode-cookbooks/build-essential/tree/v2.0.2) | -chef_handler| [1.1.6](https://github.com/opscode-cookbooks/chef_handler/tree/v1.1.6) | -chef_handler_sns| [1.0.0](https://github.com/onddo/chef_handler_sns-cookbook/tree/1.0.0) | +build-essential| [2.0.2](https://github.com/opscode-cookbooks/build-essential/tree/v2.0.2) | +chef_handler| [1.1.6](https://github.com/opscode-cookbooks/chef_handler/tree/v1.1.6) | +chef_handler_sns| [1.0.0](https://github.com/onddo/chef_handler_sns-cookbook/tree/1.0.0) | cron| [1.3.12](https://github.com/opscode-cookbooks/cron/tree/v1.3.12) | - We are using 1.3.0, with a backported libraries/matchers.rb from 1.3.12 +erlang | [1.5.6](https://github.com/opscode-cookbooks/erlang/commit/2af91e4650c1411fbf8e44626b1a548f777926c4) | ignored in our cs/test setup fail2ban | 2.2.1 | removed yum dependencies, adapted to our rubocop scheme, changed attributes/default.rb -ohai| 2.0.1 | +ohai| 2.0.1 | +rabbitmq | [3.4.0](https://github.com/jjasghar/rabbitmq/commit/b71c0a068419ad10324e8d13b517fafbf373c0c3) | removed yum, ignored in our cs/test setup xml| [1.2.4](https://github.com/opscode-cookbooks/xml/tree/v1.2.4) | -python | [master](https://github.com/poise/python/commit/56424ab64b06f584c13dba2dbb1cc5369faf20f4) | +python | [master](https://github.com/poise/python/commit/56424ab64b06f584c13dba2dbb1cc5369faf20f4) | diff --git a/apt/metadata.rb b/apt/metadata.rb index 2b8d435b9..a4c3f989d 100644 --- a/apt/metadata.rb +++ b/apt/metadata.rb @@ -3,7 +3,7 @@ maintainer_email 'till@php.net' license 'Apache 2.0' description 'Configures apt and apt services' -version '0.10.0' +version '2.5.3' recipe 'apt', 'Runs apt-get update during compile phase and sets up preseed directories' recipe 'apt::proxy', 'Set up an APT proxy' recipe 'apt::ppa', 'Setup the tools needed to initialize PPAs' diff --git a/easybib/metadata.rb b/easybib/metadata.rb index 5133396dc..b7d9b9a84 100644 --- a/easybib/metadata.rb +++ b/easybib/metadata.rb @@ -50,6 +50,7 @@ depends 'postfix' depends 'redis' depends 'rsyslogd' +depends 'service' depends 'snooze' depends 'hhvm-fcgi' depends 'statsd' diff --git a/easybib/recipes/role-gearmand.rb b/easybib/recipes/role-gearmand.rb index 5dd69c8d0..92ea0cab9 100644 --- a/easybib/recipes/role-gearmand.rb +++ b/easybib/recipes/role-gearmand.rb @@ -1,3 +1,3 @@ -include_recipe 'easybib::setup' -include_recipe 'loggly::setup' -include_recipe 'gearmand' +Chef::Log.info('This is deprecated, please update to service::role-gearmand') + +include_recipe 'service::role-gearmand' diff --git a/erlang/.gitignore b/erlang/.gitignore new file mode 100644 index 000000000..dd1e4255b --- /dev/null +++ b/erlang/.gitignore @@ -0,0 +1,14 @@ +.vagrant +Berksfile.lock +Gemfile.lock +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +.bundle +.cache +.kitchen +bin +.kitchen.local.yml diff --git a/erlang/.kitchen.yml b/erlang/.kitchen.yml new file mode 100644 index 000000000..c569c02e0 --- /dev/null +++ b/erlang/.kitchen.yml @@ -0,0 +1,79 @@ +--- +driver_plugin: vagrant +driver_plugin: digitalocean +driver_config: + digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %> + digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %> + aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> + aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> + aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %> + ssh_key: <%= ENV['AWS_PRIVATE_KEY_PATH'] %> + rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %> + rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %> + require_chef_omnibus: latest + +platforms: +- name: centos-5.8 + driver_plugin: digitalocean + driver_config: + image_id: 1601 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: centos-6.4 + driver_plugin: digitalocean + driver_config: + image_id: 562354 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: amazon-2013.09 + driver_plugin: ec2 + driver_config: + image_id: ami-3be4bc52 + username: ec2-user + +- name: ubuntu-10.04 + driver_plugin: digitalocean + driver_config: + image_id: 14097 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt::default] + +- name: ubuntu-12.04 + driver_plugin: digitalocean + driver_config: + image_id: 1505447 + flavor_id: 63 + region_id: 1 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt::default] + +suites: +- name: default + run_list: + - 'recipe[erlang]' + attributes: {} + +- name: gui_tools + run_list: + - 'recipe[erlang]' + attributes: { erlang: { gui_tools: true } } + excludes: ['centos-5.8', 'centos-6.4', 'amazon-2013.09'] + +- name: esl + run_list: + - 'recipe[erlang::esl]' + attributes: {} + excludes: ['centos-5.8'] + +- name: source + run_list: + - 'recipe[erlang::source]' + attributes: {} diff --git a/erlang/.rubocop.yml b/erlang/.rubocop.yml new file mode 100644 index 000000000..f18e2d22b --- /dev/null +++ b/erlang/.rubocop.yml @@ -0,0 +1,8 @@ +Encoding: + Enabled: false + +LineLength: + Max: 200 + +HashSyntax: + EnforcedStyle: hash_rockets diff --git a/erlang/.travis.yml b/erlang/.travis.yml new file mode 100644 index 000000000..0e419f52c --- /dev/null +++ b/erlang/.travis.yml @@ -0,0 +1,13 @@ +language: ruby +bundler_args: --without development integration +rvm: + - 1.9.3 + - 2.0.0 +before_install: + - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" +before_script: + - bundle exec berks install +script: +# - bundle exec foodcritic -f any . --tags ~FC005 + - bundle exec rubocop +# - bundle exec rspec --color --format progress diff --git a/erlang/Berksfile b/erlang/Berksfile new file mode 100644 index 000000000..efe106bd8 --- /dev/null +++ b/erlang/Berksfile @@ -0,0 +1,11 @@ +site :opscode + +metadata + +group :integration do + cookbook 'apt' + cookbook 'minitest-handler' + cookbook 'yum', '~> 3.0' + cookbook 'yum-epel' + cookbook 'yum-repoforge' +end diff --git a/erlang/CHANGELOG.md b/erlang/CHANGELOG.md new file mode 100644 index 000000000..3eb17dd3d --- /dev/null +++ b/erlang/CHANGELOG.md @@ -0,0 +1,76 @@ +erlang Cookbook CHANGELOG +========================= +This file is used to list changes made in each version of the erlang cookbook. + +v1.5.6 (2014-07-29) +------------------- +#16 - Allow for systems with that do not have lsb installed + +v1.5.4 (2014-04-30) +------------------- +- [COOK-4610] - New APT repository for ESL + + +v1.5.2 (2014-03-18) +------------------- +- [COOK-4296] Add an attribute for passing CFLAGS prior to compilation + + +v1.5.0 (2014-02-25) +------------------- +[COOK-4296] - Add custom build flags when building from source + + +v1.4.2 +------ +COOK-4155, use a version in version conditional + +v1.4.0 +------ +Porting to use cookbook yum ~> 3.0 +Moving tests from minitest to bats +Fixing style against rubocop + + +v1.3.6 +------ +fixing metadata version error. locking to 3.0 + + +v1.3.4 +------ +Locking yum dependency to '< 3' + + +v1.3.2 +------ +### New Feature +- **[COOK-2915](https://tickets.opscode.com/browse/COOK-2915)** - Debian codename override + +v1.3.0 +------ +- Add support for Test Kitchen 1.0 + +### Bug +- [COOK-2595]: erlang cookbook now incorrectly depends on apt <= 1.7.0 +- [COOK-2894]: erlang::esl uses nil attribute + +### Improvement +- [COOK-2509]: Add support for installing Erlang/OTP from Erlang Solutions' repositories + +v1.2.0 +------ +- [COOK-2287] - Add support for installing Erlang from source + +v1.1.2 +------ +- [COOK-1215] - Support Amazon Linux in erlang cookbook +- [COOK-1884] - Erlang Readme does not reflect cookbook requirements + +v1.1.0 +------ +- [COOK-1782] - Add test kitchen support + +v1.0.0 +------ +- [COOK-905] - Fix installation on RHEL/CentOS 6+ diff --git a/erlang/CONTRIBUTING.md b/erlang/CONTRIBUTING.md new file mode 100644 index 000000000..3a9989787 --- /dev/null +++ b/erlang/CONTRIBUTING.md @@ -0,0 +1,257 @@ +# Contributing to Opscode Cookbooks + +We are glad you want to contribute to Opscode Cookbooks! The first +step is the desire to improve the project. + +You can find the answers to additional frequently asked questions +[on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute). + +You can find additional information about +[contributing to cookbooks](http://wiki.opscode.com/display/chef/How+to+Contribute+to+Opscode+Cookbooks) +on the wiki as well. + +## Quick-contribute + +* Create an account on our [bug tracker](http://tickets.opscode.com) +* Sign our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) +(keep reading if you're contributing on behalf of your employer) +* Create a ticket for your change on the + [bug tracker](http://tickets.opscode.com) +* Link to your patch as a rebased git branch or pull request from the + ticket +* Resolve the ticket as fixed + +We regularly review contributions and will get back to you if we have +any suggestions or concerns. + +## The Apache License and the CLA/CCLA + +Licensing is very important to open source projects, it helps ensure +the software continues to be available under the terms that the author +desired. Chef uses the Apache 2.0 license to strike a balance between +open contribution and allowing you to use the software however you +would like to. + +The license tells you what rights you have that are provided by the +copyright holder. It is important that the contributor fully +understands what rights they are licensing and agrees to them. +Sometimes the copyright holder isn't the contributor, most often when +the contributor is doing work for a company. + +To make a good faith effort to ensure these criteria are met, Opscode +requires a Contributor License Agreement (CLA) or a Corporate +Contributor License Agreement (CCLA) for all contributions. This is +without exception due to some matters not being related to copyright +and to avoid having to continually check with our lawyers about small +patches. + +It only takes a few minutes to complete a CLA, and you retain the +copyright to your contribution. + +You can complete our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L). +If you're contributing on behalf of your employer, have your employer +fill out our +[Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) +instead. + +## Ticket Tracker (JIRA) + +The [ticket tracker](http://tickets.opscode.com) is the most important +documentation for the code base. It provides significant historical +information, such as: + +* Which release a bug fix is included in +* Discussion regarding the design and merits of features +* Error output to aid in finding similar bugs + +Each ticket should aim to fix one bug or add one feature. + +## Using git + +You can get a quick copy of the repository for this cookbook by +running `git clone +git://github.com/opscode-coobkooks/COOKBOOKNAME.git`. + +For collaboration purposes, it is best if you create a Github account +and fork the repository to your own account. Once you do this you will +be able to push your changes to your Github repository for others to +see and use. + +If you have another repository in your GitHub account named the same +as the cookbook, we suggest you suffix the repository with -cookbook. + +### Branches and Commits + +You should submit your patch as a git branch named after the ticket, +such as COOK-1337. This is called a _topic branch_ and allows users to +associate a branch of code with the ticket. + +It is a best practice to have your commit message have a _summary +line_ that includes the ticket number, followed by an empty line and +then a brief description of the commit. This also helps other +contributors understand the purpose of changes to the code. + + [COOK-1757] - platform_family and style + + * use platform_family for platform checking + * update notifies syntax to "resource_type[resource_name]" instead of + resources() lookup + * COOK-692 - delete config files dropped off by packages in conf.d + * dropped debian 4 support because all other platforms have the same + values, and it is older than "old stable" debian release + +Remember that not all users use Chef in the same way or on the same +operating systems as you, so it is helpful to be clear about your use +case and change so they can understand it even when it doesn't apply +to them. + +### Github and Pull Requests + +All of Opscode's open source cookbook projects are available on +[Github](http://www.github.com/opscode-cookbooks). + +We don't require you to use Github, and we will even take patch diffs +attached to tickets on the tracker. However Github has a lot of +convenient features, such as being able to see a diff of changes +between a pull request and the main repository quickly without +downloading the branch. + +If you do choose to use a pull request, please provide a link to the +pull request from the ticket __and__ a link to the ticket from the +pull request. Because pull requests only have two states, open and +closed, we can't easily filter pull requests that are waiting for a +reply from the author for various reasons. + +### More information + +Additional help with git is available on the +[Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git) +wiki page. + +## Functional and Unit Tests + +This cookbook is set up to run tests under +[Opscode's test-kitchen](https://github.com/opscode/test-kitchen). It +uses minitest-chef to run integration tests after the node has been +converged to verify that the state of the node. + +Test kitchen should run completely without exception using the default +[baseboxes provided by Opscode](https://github.com/opscode/bento). +Because Test Kitchen creates VirtualBox machines and runs through +every configuration in the Kitchenfile, it may take some time for +these tests to complete. + +If your changes are only for a specific recipe, run only its +configuration with Test Kitchen. If you are adding a new recipe, or +other functionality such as a LWRP or definition, please add +appropriate tests and ensure they run with Test Kitchen. + +If any don't pass, investigate them before submitting your patch. + +Any new feature should have unit tests included with the patch with +good code coverage to help protect it from future changes. Similarly, +patches that fix a bug or regression should have a _regression test_. +Simply put, this is a test that would fail without your patch but +passes with it. The goal is to ensure this bug doesn't regress in the +future. Consider a regular expression that doesn't match a certain +pattern that it should, so you provide a patch and a test to ensure +that the part of the code that uses this regular expression works as +expected. Later another contributor may modify this regular expression +in a way that breaks your use cases. The test you wrote will fail, +signalling to them to research your ticket and use case and accounting +for it. + +If you need help writing tests, please ask on the Chef Developer's +mailing list, or the #chef-hacking IRC channel. + +## Code Review + +Opscode regularly reviews code contributions and provides suggestions +for improvement in the code itself or the implementation. + +We find contributions by searching the ticket tracker for _resolved_ +tickets with a status of _fixed_. If we have feedback we will reopen +the ticket and you should resolve it again when you've made the +changes or have a response to our feedback. When we believe the patch +is ready to be merged, we will tag the _Code Reviewed_ field with +_Reviewed_. + +Depending on the project, these tickets are then merged within a week +or two, depending on the current release cycle. + +## Release Cycle + +The versioning for Opscode Cookbook projects is X.Y.Z. + +* X is a major release, which may not be fully compatible with prior + major releases +* Y is a minor release, which adds both new features and bug fixes +* Z is a patch release, which adds just bug fixes + +A released version of a cookbook will end in an even number, e.g. +"1.2.4" or "0.8.0". When development for the next version of the +cookbook begins, the "Z" patch number is incremented to the next odd +number, however the next release of the cookbook may be a major or +minor incrementing version. + +Releases of Opscode's cookbooks are usually announced on the Chef user +mailing list. Releases of several cookbooks may be batched together +and announced on the [Opscode Blog](http://www.opscode.com/blog). + +## Working with the community + +These resources will help you learn more about Chef and connect to +other members of the Chef community: + +* [chef](http://lists.opscode.com/sympa/info/chef) and + [chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing + lists +* #chef and #chef-hacking IRC channels on irc.freenode.net +* [Community Cookbook site](http://community.opscode.com) +* [Chef wiki](http://wiki.opscode.com/display/chef) +* Opscode Chef [product page](http://www.opscode.com/chef) + + +## Cookbook Contribution Do's and Don't's + +Please do include tests for your contribution. If you need help, ask +on the +[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev) +or the +[#chef-hacking IRC channel](http://community.opscode.com/chat/chef-hacking). +Not all platforms that a cookbook supports may be supported by Test +Kitchen. Please provide evidence of testing your contribution if it +isn't trivial so we don't have to duplicate effort in testing. Chef +10.14+ "doc" formatted output is sufficient. + +Please do indicate new platform (families) or platform versions in the +commit message, and update the relevant ticket. + +If a contribution adds new platforms or platform versions, indicate +such in the body of the commit message(s), and update the relevant +COOK ticket. When writing commit messages, it is helpful for others if +you indicate the COOK ticket. For example: + + git commit -m '[COOK-1041] - Updated pool resource to correctly + delete.' + +Please do use [foodcritic](http://acrmp.github.com/foodcritic) to +lint-check the cookbook. Except FC007, it should pass all correctness +rules. FC007 is okay as long as the dependent cookbooks are *required* +for the default behavior of the cookbook, such as to support an +uncommon platform, secondary recipe, etc. + +Please do ensure that your changes do not break or modify behavior for +other platforms supported by the cookbook. For example if your changes +are for Debian, make sure that they do not break on CentOS. + +Please do not modify the version number in the metadata.rb, Opscode +will select the appropriate version based on the release cycle +information above. + +Please do not update the CHANGELOG.md for a new version. Not all +changes to a cookbook may be merged and released in the same versions. +Opscode will update the CHANGELOG.md when releasing a new version of +the cookbook. diff --git a/erlang/Gemfile b/erlang/Gemfile new file mode 100644 index 000000000..f465c7829 --- /dev/null +++ b/erlang/Gemfile @@ -0,0 +1,13 @@ +source 'https://rubygems.org' + +gem 'berkshelf', '~> 2.0' +gem 'chefspec', '~> 3.0' +gem 'foodcritic', '~> 3.0' +gem 'rubocop' + +group :integration do + gem 'test-kitchen', '~> 1.0' + gem 'kitchen-vagrant', '~> 0.11' + gem 'kitchen-digitalocean' + gem 'kitchen-ec2' +end diff --git a/erlang/LICENSE b/erlang/LICENSE new file mode 100644 index 000000000..11069edd7 --- /dev/null +++ b/erlang/LICENSE @@ -0,0 +1,201 @@ + 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/erlang/README.md b/erlang/README.md new file mode 100644 index 000000000..7ac3ec79d --- /dev/null +++ b/erlang/README.md @@ -0,0 +1,92 @@ +Description +=========== + +Manages installation of Erlang via packages or source. + +Requirements +============ + +## Chef + +Chef version 0.10.10+ and Ohai 0.6.12+ are required + +## Platform + +Tested on: + +* Ubuntu 10.04, 11.10, 12.04 +* Red Hat Enterprise Linux (CentOS/Amazon/Scientific/Oracle) 5.7, 6.2 + +**Notes**: This cookbook has been tested on the listed platforms. It + may work on other platforms with or without modification. + +## Cookbooks + +* yum (for epel recipe) +* build-essential (for source compilation) + +Attributes +========== + +* `node['erlang']['gui_tools']` - whether to install the GUI tools for + Erlang. +* `node['erlang']['install_method']` - Erlang installation method + ("package", "source", or "esl" (for Erlang Solutions packages)). +* `node['erlang']['source']['version']` - Version of Erlang/OTP to install from source. + "source") +* `node['erlang']['source']['url']` - URL of Erlang/OTP source tarball. +* `node['erlang']['source']['checksum']` - Checksum of the Erlang/OTP source tarball. +* `node['erlang']['source']['build_flags']` - Build flags for compiling Erlang/OTP. +* `node['erlang']['source']['cflags']` - CFLAGS for configuring Erlang/OTP. +* `node['erlang']['esl']['version']` - version specifier for Erlang + Solutions packages. +* `node['erlang']['esl']['lsb_codename']` - override the code name + used for ESL packages, useful for installing the packages on + distributions that they don't make specific packages available + (e.g., maverick vs precise). + +Recipes +======= + +## default + +Manages installation of Erlang. Includes the package or source recipe +depending on the value of `node['erlang']['install_method']`. + +## package + +Installs Erlang from distribution packages. + +## source + +Installs Erlang from source. + +## erlang_solutions + +Adds Erlang Solutions' [package repositories][] on Debian, CentOS (> +5), and Fedora systems, and installs the `esl-erlang` package. + +[package repositories]:https://www.erlang-solutions.com/downloads/download-erlang-otp + +License and Author +================== + +* Author: Joe Williams () +* Author: Joshua Timberman () +* Author: Matt Ray () +* Author: Hector Castro () +* Author: Christopher Maier () + +Copyright 2011-2013, Opscode, Inc. + +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/erlang/TESTING.md b/erlang/TESTING.md new file mode 100644 index 000000000..e29ff7c04 --- /dev/null +++ b/erlang/TESTING.md @@ -0,0 +1,25 @@ +This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements. + +1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site. +2. You must have Vagrant 1.1 installed. +3. You must have a "sane" Ruby 1.9.3 environment. + +Once the above requirements are met, install the additional requirements: + +Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment. + + vagrant plugin install vagrant-berkshelf + gem install berkshelf + +Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version). + + gem install test-kitchen --pre + +Install the Vagrant driver for Test Kitchen. + + gem install kitchen-vagrant + +Once the above are installed, you should be able to run Test Kitchen: + + kitchen list + kitchen test diff --git a/erlang/attributes/default.rb b/erlang/attributes/default.rb new file mode 100644 index 000000000..82ef0be49 --- /dev/null +++ b/erlang/attributes/default.rb @@ -0,0 +1,28 @@ +# +# Author:: Joshua Timberman +# Copyright:: Copyright (c) 2012, Opscode, Inc. +# +# 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. +# + +default['erlang']['gui_tools'] = false +default['erlang']['install_method'] = 'package' + +default['erlang']['source']['version'] = 'R15B01' +default['erlang']['source']['url'] = "http://erlang.org/download/otp_src_#{node['erlang']['source']['version']}.tar.gz" +default['erlang']['source']['checksum'] = 'f94f7de7328af3c0cdc42089c1a4ecd03bf98ec680f47eb5e6cddc50261cabde' +default['erlang']['source']['build_flags'] = '' +default['erlang']['source']['cflags'] = '' + +default['erlang']['esl']['version'] = nil +default['erlang']['esl']['lsb_codename'] = node['lsb'] ? node['lsb']['codename'] : 'no_lsb' diff --git a/erlang/chefignore b/erlang/chefignore new file mode 100644 index 000000000..a6de14221 --- /dev/null +++ b/erlang/chefignore @@ -0,0 +1,96 @@ +# Put files/directories that should be ignored in this file when uploading +# or sharing to the community site. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +Guardfile +Procfile + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Cookbooks # +############# +CONTRIBUTING +CHANGELOG* + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile + +# Travis # +########## +.travis.yml diff --git a/erlang/metadata.rb b/erlang/metadata.rb new file mode 100644 index 000000000..63f844554 --- /dev/null +++ b/erlang/metadata.rb @@ -0,0 +1,21 @@ +name 'erlang' +maintainer 'Opscode, Inc.' +maintainer_email 'cookbooks@opscode.com' +license 'Apache 2.0' +description 'Installs erlang, optionally install GUI tools.' +version '1.5.6' + +depends 'apt', '>= 1.7.0' +# depends 'yum', '~> 3.0' +# depends 'yum-epel' +# depends 'yum-erlang_solutions' +depends 'build-essential' + +recipe 'erlang', 'Installs Erlang via native package, source, or Erlang Solutions package' +recipe 'erlang::package', 'Installs Erlang via native package' +recipe 'erlang::source', 'Installs Erlang via source' +recipe 'erlang::esl', "Installs Erlang from Erlang Solutions' package repositories" + +%w(ubuntu debian).each do |os| + supports os +end diff --git a/erlang/recipes/default.rb b/erlang/recipes/default.rb new file mode 100644 index 000000000..283049d7a --- /dev/null +++ b/erlang/recipes/default.rb @@ -0,0 +1,23 @@ +# Cookbook Name:: erlang +# Recipe:: default +# Author:: Joe Williams +# Author:: Matt Ray +# Author:: Hector Castro +# +# Copyright 2008-2009, Joe Williams +# Copyright 2011, Opscode Inc. +# +# 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. +# + +include_recipe "erlang::#{node['erlang']['install_method']}" diff --git a/erlang/recipes/esl.rb b/erlang/recipes/esl.rb new file mode 100644 index 000000000..e6a5c9cc2 --- /dev/null +++ b/erlang/recipes/esl.rb @@ -0,0 +1,66 @@ +# +# Cookbook Name:: erlang +# Recipe:: esl +# +# Author:: Christopher Maier () +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +# Install Erlang/OTP from Erlang Solutions + +case node['platform_family'] +when 'debian' + + include_recipe 'apt' + + apt_repository 'erlang_solutions_repo' do + uri 'http://packages.erlang-solutions.com/debian/' + distribution node['erlang']['esl']['lsb_codename'] + components ['contrib'] + key 'http://packages.erlang-solutions.com/debian/erlang_solutions.asc' + action :add + end + + package 'esl-erlang' do + version node['erlang']['esl']['version'] if node['erlang']['esl']['version'] + end + +when 'rhel' + if node['platform_version'].to_i <= 5 + Chef::Log.fatal('Erlang Solutions pacakge repositories are not available for EL5') + else + # include_recipe 'yum-repoforge' + include_recipe 'yum-erlang_solutions' + end + + package 'erlang' do + version node['erlang']['esl']['version'] if node['erlang']['esl']['version'] + end + +end + +# There's a small bug in the package for Ubuntu 10.04... this fixes +# it. Solution found at +# https://github.com/davidcoallier/bigcouch/blob/f6a6daf7590ecbab4d9dc4747624573b3137dfad/README.md#ubuntu-1004-lts-potential-issues +if platform?('ubuntu') && node['platform_version'] == '10.04' + bash 'ubuntu-10.04-LTS-erlang-fix' do + user 'root' + cwd '/usr/lib/erlang/man/man5' + code <<-EOS + rm modprobe.d.5 + ln -s modprobe.conf.5.gz modprobe.d.5 + EOS + end +end diff --git a/erlang/recipes/package.rb b/erlang/recipes/package.rb new file mode 100644 index 000000000..19f9fce23 --- /dev/null +++ b/erlang/recipes/package.rb @@ -0,0 +1,47 @@ +# +# Cookbook Name:: erlang +# Recipe:: default +# Author:: Joe Williams +# Author:: Matt Ray +# Author:: Hector Castro +# +# Copyright 2008-2009, Joe Williams +# Copyright 2011, Opscode Inc. +# +# 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. +# + +case node['platform_family'] +when 'debian' + erlpkg = node['erlang']['gui_tools'] ? 'erlang-x11' : 'erlang-nox' + package erlpkg + package 'erlang-dev' + +when 'rhel' + case node['platform_version'].to_i + when 5 + include_recipe 'yum-epel' + + yum_repository 'EPELErlangrepo' do + description "Updated erlang yum repository for RedHat / Centos 5.x - #{node['kernel']['machine']}" + baseurl 'http://repos.fedorapeople.org/repos/peter/erlang/epel-5Server/$basearch' + gpgcheck false + action :create + end + + else + include_recipe 'yum-erlang_solutions' + end + + package 'erlang' +end diff --git a/erlang/recipes/source.rb b/erlang/recipes/source.rb new file mode 100644 index 000000000..a0a4b1b20 --- /dev/null +++ b/erlang/recipes/source.rb @@ -0,0 +1,57 @@ +# Cookbook Name:: erlang +# Recipe:: default +# Author:: Joe Williams +# Author:: Matt Ray +# Author:: Hector Castro +# +# Copyright 2008-2009, Joe Williams +# Copyright 2011, Opscode Inc. +# +# 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. +# + +include_recipe 'build-essential' + +erlang_deps = case node['platform_family'] + when 'debian' + %w(libncurses5-dev openssl libssl-dev) + when 'rhel', 'fedora' + %w(ncurses-devel openssl-devel) + else + [] + end + +erlang_deps.each do |pkg| + package pkg do + action :install + end +end + +bash 'install-erlang' do + cwd Chef::Config[:file_cache_path] + code <<-EOH + tar -xzf otp_src_#{node['erlang']['source']['version']}.tar.gz + (cd otp_src_#{node['erlang']['source']['version']} && ./configure #{node['erlang']['source']['build_flags']} && make && make install) + EOH + environment('CFLAGS' => node['erlang']['source']['cflags']) + action :nothing + not_if "erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell | grep #{node['erlang']['source']['version']}" +end + +remote_file File.join(Chef::Config[:file_cache_path], "otp_src_#{node['erlang']['source']['version']}.tar.gz") do + source node['erlang']['source']['url'] + owner 'root' + mode 0644 + checksum node['erlang']['source']['checksum'] + notifies :run, 'bash[install-erlang]', :immediately +end diff --git a/erlang/spec/spec_helper.rb b/erlang/spec/spec_helper.rb new file mode 100644 index 000000000..1dd5126bf --- /dev/null +++ b/erlang/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/erlang/test/integration/default/bats/run_an_erlang_command.sh b/erlang/test/integration/default/bats/run_an_erlang_command.sh new file mode 100644 index 000000000..ee6e61f6c --- /dev/null +++ b/erlang/test/integration/default/bats/run_an_erlang_command.sh @@ -0,0 +1,5 @@ +@test "run an erl command" { + sudo bash -c 'erl -myflag 1 <<-EOH +init:get_argument(myflag). +EOH' +} diff --git a/erlang/test/integration/esl/bats/run_an_erlang_command.sh b/erlang/test/integration/esl/bats/run_an_erlang_command.sh new file mode 100644 index 000000000..ee6e61f6c --- /dev/null +++ b/erlang/test/integration/esl/bats/run_an_erlang_command.sh @@ -0,0 +1,5 @@ +@test "run an erl command" { + sudo bash -c 'erl -myflag 1 <<-EOH +init:get_argument(myflag). +EOH' +} diff --git a/erlang/test/integration/source/bats/run_an_erlang_command.sh b/erlang/test/integration/source/bats/run_an_erlang_command.sh new file mode 100644 index 000000000..ee6e61f6c --- /dev/null +++ b/erlang/test/integration/source/bats/run_an_erlang_command.sh @@ -0,0 +1,5 @@ +@test "run an erl command" { + sudo bash -c 'erl -myflag 1 <<-EOH +init:get_argument(myflag). +EOH' +} diff --git a/nginx-app/recipes/sitescraper.rb b/nginx-app/recipes/sitescraper.rb index f08b63016..b64a817f1 100644 --- a/nginx-app/recipes/sitescraper.rb +++ b/nginx-app/recipes/sitescraper.rb @@ -3,10 +3,12 @@ access_log = node['nginx-app']['access_log'] easybib_nginx config do - app_name 'sitescraper' + app_name config config_template 'internal-api.conf.erb' doc_root 'www' access_log access_log nginx_extras 'sendfile off;' notifies :restart, 'service[nginx]', :delayed end + +easybib_envconfig config diff --git a/rabbitmq/.gitignore b/rabbitmq/.gitignore new file mode 100644 index 000000000..7a0d26fb1 --- /dev/null +++ b/rabbitmq/.gitignore @@ -0,0 +1,15 @@ +.vagrant +Berksfile.lock +Gemfile.lock +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +.bundle +.cache +.kitchen +bin +.kitchen.local.yml +.coverage \ No newline at end of file diff --git a/rabbitmq/.kitchen.cloud.yml b/rabbitmq/.kitchen.cloud.yml new file mode 100644 index 000000000..6d3a1cbc5 --- /dev/null +++ b/rabbitmq/.kitchen.cloud.yml @@ -0,0 +1,94 @@ +--- +driver_config: + digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %> + digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %> + aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> + aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> + aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %> + +provisioner: + name: chef_zero + require_chef_omnibus: latest + +platforms: +- name: centos-5.8 + driver_plugin: digitalocean + driver_config: + image_id: 1601 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %> + +- name: centos-6.4 + driver_plugin: digitalocean + driver_config: + image_id: 562354 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %> + +- name: amazon-2013.09 + driver_plugin: ec2 + driver_config: + image_id: ami-3be4bc52 + username: ec2-user + ssh_key: <%= ENV['EC2_SSH_KEY_PATH'] %> + +- name: debian-70 + driver_plugin: digitalocean + driver_config: + image_id: 308287 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1004 + driver_plugin: digitalocean + driver_config: + image_id: 14097 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1204 + driver_plugin: digitalocean + driver_config: + image_id: 1505447 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1304 + driver_plugin: digitalocean + driver_config: + image_id: 350076 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1310 + driver_plugin: digitalocean + driver_config: + image_id: 1505699 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +suites: +- name: default + run_list: + - recipe[minitest-handler] + - recipe[rabbitmq::default] + attributes: {} diff --git a/rabbitmq/.kitchen.yml b/rabbitmq/.kitchen.yml new file mode 100644 index 000000000..d5711222d --- /dev/null +++ b/rabbitmq/.kitchen.yml @@ -0,0 +1,26 @@ +driver: + name: vagrant + +provisioner: + name: chef_zero + +platforms: + - name: centos-5.10 + - name: centos-6.5 + - name: ubuntu-12.04 + - name: ubuntu-14.04 + +suites: + - name: default + run_list: + - recipe[rabbitmq::default] + - name: cluster + run_list: + - recipe[rabbitmq::default] + attributes: + rabbitmq: + cluster: true + cluster_disk_nodes: ['rabbit@localhost'] + - name: lwrps + run_list: + - recipe[rabbitmq_test::lwrps] diff --git a/rabbitmq/.rubocop.yml b/rabbitmq/.rubocop.yml new file mode 100644 index 000000000..07589d810 --- /dev/null +++ b/rabbitmq/.rubocop.yml @@ -0,0 +1,17 @@ +AlignParameters: + Enabled: false + +Encoding: + Enabled: false + +LineLength: + Max: 200 + +HashSyntax: + EnforcedStyle: hash_rockets + +AsciiComments: + Enabled: false + +MethodLength: + Max: 18 \ No newline at end of file diff --git a/rabbitmq/.travis.yml b/rabbitmq/.travis.yml new file mode 100644 index 000000000..7dcbd4db1 --- /dev/null +++ b/rabbitmq/.travis.yml @@ -0,0 +1,74 @@ +language: ruby +bundler_args: --without kitchen_vagrant +rvm: +- 2.1.0 +before_install: +- echo -n $DO_KEY_CHUNK_{0..30} >> ~/.ssh/id_do.base64 +- cat ~/.ssh/id_do.base64 | tr -d ' ' | base64 --decode > ~/.ssh/id_do.pem +- echo -n $EC2_KEY_CHUNK_{0..30} >> ~/.ssh/id_ec2.base64 +- cat ~/.ssh/id_ec2.base64 | tr -d ' ' | base64 --decode > ~/.ssh/id_ec2.pem +script: +- bundle exec rake travis +after_script: +- bundle exec kitchen destroy +env: + global: + - secure: azjR7jwSlkSSx61D9WYoil0BB/ztHnud17F9nDfmqHIacgjO8szyQfF18eKal8/iPCFii4RrsTytHE1iEckbTqCssfg1QeFPjYZpllY0tKTjF5L3+DGn+pLrouhfwJpxo1Lo4s5wD0z4uFiAcGVJtw8I/Xh+xaGdOjYaVlLW/bI= + - secure: NPKRM7REdLlEJ5dMOPcqNxBHprBfODRY70J/lu6uVWeGuEpriX0JVjzC4temMMjvY4UAzQMp4INOaqV/r0XVlYQecE2WW/o9vyBLcF6CscGsE69sRJPMOyIMmBxyLDSpVRvEqQ/InB2hmrf0jF8lfm9EcASPuPD7yvfQb0x85NQ= + - secure: eWgiU283LbvB4eq0w287yxNjQVaemKWOgYrFkO5hEcNC64b2kPPw6yeqFgm0E5tt2R3b+VHF8C1CjLG4ww/C4u5lBqzi+oJodsGTN1IW0hWZrL/a62lWBgkHO1gd0eJO4apUJ9sb6MPaLrIfzc1WxClez6KXmC/MDeNGb12YJGU= + - secure: Z20rOUTQ+IXErCPPV9chV//TksNV/I0qTfK36yNQtR2pg+U7NPuocnakF+4EvpzLjFBVW+QBnI6gwoFRZzXZYkkjOYRFl9B1zt3aHkWyilzo5GosP068Eqm9c7Tnwts7VSym962DBDn6u/rmQt5f0bOiy7T2jhSipnLIg58g780= + - secure: g9Xb822U72BgEWPEDbqeNZRueN+JSrw4nz/C/Nwy4MgFDrrSyO4YjzkH+I50RXc+AUkpcAqFdU7Z6qDi+CVZas2C9ag4eq5bCwK0RGHRfwGbiYVePfUBjiYWG7ysH3MgJ9nCZnYK4EQSP1xstoU6aIcUUAT1GOztx9f3PBuj+As= + - secure: H2jj7HHuNlWndMyOk4OY0d8s6OxiuL+wLVXZj0WEkFvwPyueYT32e78KVSBbjXG+mhogtOXz1Q9QXrURTlzKyCJGa6lvCAuPBFGCGCMZnlOhvZlEs+STui1qEQ5uGl9Bksow0xSmXczWLisEEU+BcsM1fOlQZ2mUm2B8OuugWD0= + - secure: kwUXGf0OQxiwT6ffAT64+Umhn0Yf1ijX2i3l1w5/bJ/wn1KW6z/O3admu1G3g7oMA1OO5Z+l4qgvckdaRoDqdqp30iIyPdDWxsyYVGZcgHaDM9kDmmkDqeYFochFFZhhVBVog3zz+P28s6l89Rur0QPrCiZisOh38A8qwyj/aa0= + - secure: BN35OVUDkNTFyhKD6gKhbPsMmIP+ffmqJHeceTnKCGX6rKr0OCXYXRzXGWm72pfUQ/zSGNZrhC+xfpcMxj5TM3ySOyIsC8jzu0ozZ6BOvJekHtj7laMOSnRZPe7ONcE/j3XSo8/OY9jlP/Buojv6btVcMZOjQWaMMu0/g1gxPsE= + - secure: ZBCCT6EVRa/IQ7VuG4TtI+KHqeGQNJ/W95U+ll6iLO/VdGEtOi8qUgrYIglypmnihZNNDFdQU/yeFCLAzqbLtzOiBXZR0THbPPjWv9oIBRhcdYddz8p6I7MFQINDhAwSqE8BHvcPXS/XndATaD2A4qzHHILp1MP9S0RKAGVZsw8= + - secure: hmdOgupqDuW9Rvv3LR7r53unaVrY/CbLaiHHiEVXNzCLeBsCbs3okhg60iNYVzvxMJ98gBe1FJA2JMPUwdZWkP1IzfQgxT0uV1GPlXi6ug76rBQ+QS7EmlbgSTgZMxecMjmcLNrm3BFeEWbwta0X1DNAQ3s2r+xyfUyKaaRTYag= + - secure: YTS3w+4i5Zy+t+EKKEZC6k2H5E921zSFhq2EXIP5KRnrz2sUkkknBJIpQAo4KmvoJBWzmkwlIeIvb68MBaS+Nu0Pg9cNx7C699ZF5khcjnLeVg0vp/hUbHJsqJkJrnGLJc0ictZ2kbc+UMScNfm4Vu+0cf4VHrQjBE6tqZUqb2o= + - secure: MJHjwrJAXf1h9eEkMWMkuIBEpr1jiT+GYwT6HcYzpsXvpBNWVK9RPzdmO4rDyDQsyqCeS23mir5/foNd5nYnYiidckThtCrkjDng632Rt0u6IDi1bLLnPYmX9Vl/Qb9vhNMnOsPzhh7DTNQsjVO0dkfCaosG9UOz9xkYlPDbBbo= + - secure: WfIz/WvIEbI1k4PSqsnDwvPk5vxcf96UvZa86ec9+h6jbPc8pO5/cQqMyAxEkzkQ0KLd2Hi9ci525vicuoeBQyE9cMQ365z5Z26u/PBwbK3BtPWjc/k8LeEoKmOGOpNT0rpiXcEs00bWtjJpqxl/tvI3rlZ1mFcH0aOQjJ5uq7Y= + - secure: eyw7iAVb+1Ug6hlIx1u2I+5DLo5VcPxZAxzVNOQcj1jaAmBsG0TlHQKhMQQV/5DMghp90nvJYM91UIcPn4xaAFzr9NoOAyFRtvJOJOm6Fv553pgSwmOko1namyPe1ewyXn6zX/gRrPOxCuRYWT0nm8HlW0xFJIGn/dDVZDWFPCo= + - secure: iQPuZ7hRJ4bYm+PGTLsOF7x/VHjHGijNc3zsMrhkdRnoPai8s7oCoJU95p8xvsyYs1WjVjyPlKNsStw/0856v+iXmkrmTEKnjYsQaZpP0IZcKChEaRECaDxF2mvOOzMJ8vrIuxZ+5cXHzYljA7Bb88iBfg8kVYMsZjcNW/hFIZw= + - secure: O5S9shUoBkQYiB6tcWGMCJmhz6S6CyZS6+LFXc33Mb+cqWiJOdu3LA88tGhhcA3m5guYUiNg3A3VrLIf/fmYu2vwJR5dPYu5TEOZQaC/fu5Jreff2StP9srTff/a82tb8n6Do/X3EUkSnLBOazJhS953nTbDqETSIcA+6Rq5rhg= + - secure: CoCGwqt0ZByQB5CqieGA2MMgMMD76R6VxZTI35vhEbelVOO0yMtkEmdQgKs8qa+82Tss8caB4buEoqwEhmagPXfQClWY45iOfJSPBUhwgqQZtcl8NF+cYvOgmZVGaECsWCklOyXN9a329tOvdBCqnEnKISStFRloM5j1JH65MCY= + - secure: JDdPbBZBiOxjPLQpo8cyWXWvLVB3c9ihhPphBjAUNFvW2LVyq2DWPlzosb0hM+yWMCK2k73ssqk8yxVjtoGNDymGGj11nJ/VAcSeaUp59G5dPYA+uqbnYd8ZqfkHthVBX5HurK3hk1Wjfgft1vkhuhWnPY6qtHwWVBMJ5HveVF0= + - secure: bD1KvJ+b/q8aMd87GnkgwIkG1U69EEFGqsWH5bNZtNnTs6NHy2Ux+9ePR6E7ZWuFESKi/F/eWUowiGCafLfWiAabXxr3tbktgRj0vT9pu2Qsr9nLD3Q4wJkM/oB9kHKpAc7emnDLzYf5iDms05zuZyzMxdGeH61aG9DIk+0oX3g= + - secure: PPftRhlRPDINFyggEccjW3N/muSzokc8Lw4bVcci0fZKCd//lBRXTwmf43MMsgX8bjLWSfzGSPw9AWtLgQ3B8hvS43yNaCIr130eKWy1qDJ4loTUE6R/TKEHqPzWT0SWlTDHZr9wmKYHbjRI1nsnLy0c5Hwz4MQo7Uz02ZfaN4c= + - secure: Lk1NRLg0wnjSceQrHMnl4VOej0hVatwDCf2EmNqv2EZpLsaxsWnvvziHXLe/2a91gxMfe+6EuMpxxr3+RC4n+NGFI1ZXPu78myeCFqDVRX8f8jC0gSN5Yj+/KfxlOhAFX0j46Pb9IS3jMqmqmkIby8ae3LR19Aj1Zoe9sEb3xsU= + - secure: XCHUDTNmHacW8dC92x1Z1n19J6ynqj9rfGyy74lxpGQXsyw6nY3Cdln/jxT1ZlRE1pPqNc8EIdv/AwAjWuTxfbciRDdji/ygFypTsiqCVrm5R6TWCY845vIc5bFATA3pAzyxyrIdLY1gyAK562qCKhuTFRv8TtaY7VNe3Co570w= + - secure: Zehr1xLpC4MSnZTqNn1n5vzf8VWEo6xY9bStZCZsNDtHJmyg1/x6se11MCYCKQFEKBWLY+GD+D0NXBg1oMErrVTpcKMVECyzIe0n47dFZvTPbA5mRJ4x9MmTKYOmKfp2LUH+STtjWhQSmWLk48dSD05zUCWQEkImMRtxQhgjMz0= + - secure: fAmrQhyHl0pHFuRKiMXlnbeQ0q2KCm6dO70latpMOFRrhea9QbOEXMwNRgEoCywRtXNVELSbqI+1sCFpDq/sKuKvROs6MHZYlvKbKRoA5+viWLOwVAwxkOYeHs89u7590nJwt9mh2pkMX4K50hpZG3xLt0A8FXTZ6ZL7U7ayRvk= + - secure: SNBXfjdl0lHBNLEkCsrOYJ+EoyOrRdroywzV82rYsgoB78iH1DVQOnvl4aaxqRtWk+GCDmUI/7dEWmRCMvWJysax7xCdCRRFtjhsycjsDMmFZFaXZP6Y1qrInvQKjZuck86OwyWbMLRNJfKWDlKon4jCAtMm8CfAte5O3i5//R8= + - secure: Q7RUohxTcGehfN8GmZwbA7xYiMSrTLZJqS/s80DwBJGZ80WbT7ueNIQgRxMuXJACIoIk/nzHZ7MywtTePltX0aiCBQ0NgWuzOBR1E8LBLjZxuXgqOee8Iiwf/j1hRBA7VVWJ/kdDGLlGe33AYWLJtyAG73CpZE2Uz4qjbP7hCzQ= + - secure: CsY1FuFxWo/pfgqqr2dhROTfQqaxzvw2BZ2EajzbmA2kvphq7Ce89NQzbh0CGBMNQ3QwFMUqHpe2ugKfMP1i1zcBqS2JmTbYdDgzGsdQQ2UtEgRiwrUaCBG7ODdlrg7NcvN1Q6L36xSaiA0Eng4+Pan9PzkTWYO1fjtUuoTUK3Y= + - secure: bqI9aoyOEU7nfPbyzgRGdrCxZZre6wjb0Zb7K7f1LPcqy0+OqBPt23BRJXbI8lOt1UxyyJsxDnN9NirRH9vCrjWyrtAWEXv+JojXW/1ltbjxxUzSe0nQWVB0A1NZfOP1LIQ8bakbr1wkZXbwwwZxrY+qzsBlk5m+EGU12Sah4Ds= + - secure: cIcBpS1uaYS/lwW6KTy0PDdcr2mKxQEJMVgGLL77sPNOdoTQgZaAP21Cb881fjxujUIUMexmqcrv6exW4F350Glx1n6HKqnR+KkWuzDp15fJO1OxjUpheIgnQoaiYJkrcua6Jjr9m8p+PaLpmB3f9S0e36q2X9G6jCN8xN13gPI= + - secure: G0KsBT7JsOu4jR7G/FtpcJD63EjYTHfEDWudZ/ayAh1lvkdAiTVZMOOdy7zPQ02WbMILJ8SOlEkCGzmYXi8BCaw5krDEgtn5kEC7ZoTmbtH+YeNj5nCTVbbm1eoI9PHthDEdANyHNUWYv/CF9zK1Bj187c7LBKI6XLtfMiwpqmc= + - secure: Zlay7xrcdZxo9GlfZy8TBDdOZObYOCC1tbTMOqsbzNB2AgmFhjqhh9PK+DfAte+bdqtSBrlgs+4+xjZOD1tYUyDz7nm1a6mDp9IusHQshUpmWxhREJigEOQIOg2oSX1gUE2SnAYpgumjr6KanRBgU3sk+fVSksdk2+iTk1HDGyk= + - secure: DHjSaiBL5etTNI4KigR+6VBom/J6JqUwdgh1I/b6uRPcNui+0hWtGUDHKKJO0XDTTgt0JuWcN7mcBfwfjK8gHaN7gp65rOrCs9tS0SQ9yfKEqY2Suf3PMFo6lOtYETiMNnNm46+M2SAa4ypk6UH1T82ZZECEx9H8jtQnV8MjXuU= + - secure: SvEbFwEWDK2syCfhNJzJnARhKO+FMYgurgUn36gjZP9AaDhHFCb/M4brvN9miINXAHmTxj9/TbzxBlZ626uQpD2/ukmF0Mrp8mZl7hjpSWWHm0VKCEIb7RwtxAp/oRtfCqtC2yfseagd7rLxAaG5idHsv1KwxgUZucZ1jj4PYqk= + - secure: Di1IpnnqAt3t5P728IH6bGYxAmk6cVnBoHcR7aRN4rVabsbSTRZVFl+UJ9PHT99GsCpt+nGBD6dPN7KVbQCnyR94bvQ21GSNA3tI9DtqGPQJp5loIGWsykkmUoTqPWqn/ZnZd8JbF7XQ9bF8scf/UqrIWenfXdC6dKS6jJZhcWQ= + - secure: cDim7w+00G5gmfmxZlFOX2N3jsJcsdOrFV+aIQZWdZC843NST43pVDZ3XZFtRX3DU2ijSdnl4sF/jEPh52PafBNdwXOuJzNp9TJzM8oiey62jWSLJn96cR5kqvmj/xoxdMOWlfJ3oLXhccAoLI8mCrWfkmE9Qp2gNQuC1SnstWw= + - secure: K3I+G+MNHZLS+45ELKxoeRnV3goLMqxHxUV4e2O01zswqSYsoGbVVQNID4UM/eP37FWuXHv43YiJP9yLRqjS5a8wIFWTAIRwopCADL5YvtmajhZsi+NGZolBgDzrvgBYTbR/tqvLAZKW5zEKJo2bW0k0dLxnCbnkVEsXS0I5xro= + - secure: WoQTyxRICccnUsETvwmABpQtox/1FkV1cFlyhxaBSEWPn4TWHNLPo1LBrPZZaw3bo9D2bdpRggLJDTdgTfqLRGcmqjIf+8Y6UEsQFjCFSIIjrJiKBLXaC2UEDGA6Eg6XkDV98CuFE5k2K/ilbUBpWbgduYnh3WFe9gFVcF0pJiI= + - secure: MG07/+Sv6rBEr7LMUygsY1fCVLtf+y4amg1B8tm9juOj/Q+Q+QwjX5oAwbKi6CujPHsgRyhsJaCcpzm0y0E7wPXm5aW1qgB8tEE2Wg0G9A8NsRgo+IjgGqZjdFMhZkc+IprOeHCSgEEBv0/jB2f20eXefDhgNYrt26eKQiwSfLA= + - secure: V6uXhice6j83FbLGsdf3Vf6X63UfydGuyHxIVUgk87+pcdF8dd+1EcZiwgAdXnHo0hadl//zTIrjgxxZ/6BvVYYbSISPgb0paadW9ubN+7EIwW24jZlYOge3bWxfUWAAoIQIWawCji7HXAIZ4Xm/M4m+MCbwLy1vQ6iWStQvtrM= + - secure: G2hDHPSXFqNCZtN14nin/OFzLh22yq6IXo2lky7TnyErZ2ly8gCTqMhhVTwqv9o2EQMGPgCv+qMQgZ+heNFNaWTZiXhnS9PFxoL3cAapgl6gkZ2XpGw8TAxIRM+msNLSZspPdXpjvAiMbGeQu1wZsZIfl8nJm9IC8VSQuO9R4nc= + - secure: IIPh25E4irwXobetP0vglqaUXRyCqmlR26SHnwIHeyKIJQ8yEADcKfaOtGlF2HxKMSFJYx6svhZCDtW8HYbRcN/A1NDU4zVNu4nGbznCxhOPW21bll0IExF4kFRYWaj4L2jOrXyMIdn7HRW7CF88Ia//i2tC0RdNvUuQnODNEOc= + - secure: ZZXRwlx43Uc9igC1/sGVGUu+UrPuZP4bDOhEr7r8pZO8/ZABA9wC26XZC2n/YHbuJn2Xq+EaOavLcLQcFPisMVRjMa+C1/pqxCzzIi78ezZ9m5dHP+jRanNi4DuzxUox75VumMIiToV6lk/AMRwO8vO3O7IQNDY6JKD4TShfztY= + - secure: NAKeDv5feQ5Wi8CFuJ5L2EpnHyfcaSjzKvj5rEvzrycjmKMvDmoo/AWwiZEZ4ZhHgIQuEMysWM4LJrDaykQTRuAxflTWIxPaBCRI4cpbP+VH+K5ZC8s2+VRCq3bkOE/1iKjTTicfmPbqY01o2QEscHdU/EJwe9i0gylXREXGYCE= + - secure: ZrXI6vg00ezKAEMKFyamn9+K9/sdWbBklcFXtuZZPYT8+q7Emwu3RS9yla1UD8YyiKokQ9kwzzNx9kHkpiXafsWUUG83DfiK/6pa1V5Zk0qXkVZLZJ/UTcuQhKBjC21wG3GxGryTuohRdwJ9MQC3WG1qRYdJDNpjHeln4SSiYGo= + - secure: Ahf/aHxgxCUDYn59wRp/UQcTttSIhIY0Pv9wUzghUMUv+jsTzVLgoENVqOYevUZh4FOYjGtc1gVubo90HUltkurIUviHcc7NSlJX6sLJPyowz12nk9DA+0M86l4SmL0c2Sobb+3SK6F7wLpd0pqta3yASogjhBK+69tinOT3398= + - secure: fvCzW0GtKtl6gHn+8zJV5bh1HwdmtmgbXcRGwGLwvZBtF8khUrzEZ24sYZM+LkCMdC79U/PwLpFqXTQuvaYhQhtGjVieg5ZGDdhwDA64BZWk98l/7y8L9EOqz3MfTBTaA7223hpdUi7QzxuTEkqtviofJ3caK7RiucYhztX/Nts= + - secure: dd8fOK6ZP+pWxPqMrywu+MuEbHqs7Nel9PIyQlCVsUxjOGs76eoPYWGpXgjpj3zvFeGZ1CYRAtCDf6U/CNiurukXTCrCvPIx6wfSe9MmW/Pf1cshBPCWCiEJd9spzVcNZy28Z+z9DXQQVdLHsduAdLmT7w5BqT+Ih3LsbwSt3Bw= + - secure: TBJK+k13v7p+lrST5PM9s6/GNKApKK+RVXtN8PWa01T4drFAVbCUr8ceLrzbzMI+8qtpsCeC2m/u3B6Js4RjB5zlZKNOqXL162K5ZdECjAyIwmzXEqdiNWGMKQTPAwy3mxlSNWVl25yXangp9ht5yC4/Ha2Ow116n0AhtSconG8= + - secure: bs/pViqzDb3RY8iYjSkiVAxqIlkx66465152VwZV52p9l2a37RVwFpbgvSTdkQ3PTiNtTiXBtcqYKMY3XtLT9fStiZ4hbQ3e0ZheikArSL2G6/hWBSb+8OyonQC07DcQGXwRxQACyZSWiagss/0sE9NgHl2Zg7/M1T7Pv6hm8iI= + - secure: OUNEUx6pNOrNdm4B5z5fiAT9Yub64zkvM0nKSI0XK5rV7D1m05T64kk7mJyp3+Eern+sDsFzMOIMJcFGk12tUrPQ+s/fPoLLYIJEBVUVBcw7E8IN4e5YGkgllg0W69qKbL5NmsCLVxwSkDM3kNxp394kPicxedPYpBz4oRHcnRI= + - secure: fjCx18gyAEqHHmtfcGXgcSH6V7j486Zr4AHodnEaDGV9fOFW8YLuLOWp1IYanDwbpbVJxunQK+M1BG0uWYle7xlG39hv80tLQyA3cwPK77KmRdbycSklwXG5PIMjAJLGDpJk4k9jgx13R2bY5EGob3qbSCvzsr47thqV5Bu8SAs= + - secure: YX8OQAVH+mvf4pkw5TEVYeIGc6dv78r6xxTEk7J7dI2K4oQR65dh0mwbkE6kYPVwV+RsMIiFkpgSfAnmyBL5zidNoFS5ksLoIXLVw7hvvUHMyx5cPDhm2GkVoKXXnY/xK6MwZpxd2MF1KOB3Dp3UMpJYSFbNEHusQD3MOnuPIkk= + - secure: Gt8vsZsSU1/f1FIfThCn0Rui9+iGTkMUi7aXtbQgMIXsBHavucggMzIAi224vV+wyCIONkpjrhYYz2ghIHWMWLjtMOm3iFlXAl/BmHHyB9AzdWiJ6jFeLvexo9aBSIfPg855C1GatG4K6CoFpoOWj17ocFa7uITxlNiMCebRqXk= + - secure: D9daPoJr6RZ9GxhDR9Q5WtAIo1k9MD3+rD4IUqVRWF686XEz+/Yk2Cvuq7ZjS7U0Koru66km4sB+LNLjhdZQtbQW4QujIzrldV8jyrCTQzE2UmnhkkkyxztsoRSAIhfNh/yMjuwRf9YO1FhWhGOM/UOF9sCCnj/qr4yZbZqhniI= + - secure: CLhR4V1oMD4NfFky48Y/IsXrgvLujf5kWrQSC/UeQ54vkrMm7Xyqj77SJhN/lmooRoWbaBeeIqVqdzy7jrEkQ2qvksovli19LesPJzZ4wJ0/024XnhyQtsWslYNwYVyIjgpsr7KIP12mjdU0cE9OKxrYHJHZf0Phr7GKNz9d6RI= + - secure: WNhnp1Pt5TkqqiNMc5JTHNXvI3Xgx0LsM8Er40lxk4REq8eHoOycFeKCMn7Y0aPyB4aK+6CUAWcZ/LT+CbZ/BD/AXnXkWeKT4LELGWpeuLzUD9Z4jrZiBUVIVbse+D55ljtY+RfZzo1Ewf1N1dgaIvS2nZKiFLHz0CRGwQaMUNk= + - secure: Cnm8rshB2HFxkS7aED3GcmTrSb6n2LWb/THBJaab8l3IbrNIvd7+zP1QCRhedwxF6U3KfYRYwA4g4kAZL2QO1S1nioKNzxAqeJQ0/FhlNQ+JDeCIm8BfvQrS6Bn2W5X8rUcrXsTB8wpYyu4+CDg8QMSRvXdahQaemEl3YhsnXdQ= + - secure: FMHPE4eUlMyfHb6qFOTu7gL/LuOcbjOmLPQQ6hBQwlHUJkJLiSjKNNhsoxooUsBQq9kEnzk+YSiNn5+IDCPMGE9iKslnAkJh+ehyjtGn3Zd0vK/jHpP2Gg9eZ3XJ5CJjjQmLkgkfvGC2zuOVXn1nJ2uxDDRfEB4c4gWzqQ8uE8c= + - secure: Cqz5a1XHnfE/cSTiUZOalui9B992FGT+UUVbnIIG8x1A+7QvCYJssKIuTXz8/zXxNM6ML0VhpqSPgNgZMNHMc3fsXosbuxzp4w1a3uyZZVwPMup07iI3BE4FnxGN43Sv1n9gy7m98cAJfDv7mbgFyxeKf4CGmE5uu/eTuYQqoKI= diff --git a/rabbitmq/Berksfile b/rabbitmq/Berksfile new file mode 100644 index 000000000..d17a8e2ef --- /dev/null +++ b/rabbitmq/Berksfile @@ -0,0 +1,8 @@ +site :opscode + +metadata + +group :integration do + cookbook 'minitest-handler' + cookbook 'rabbitmq_test', :path => './test/cookbooks/rabbitmq_test' +end diff --git a/rabbitmq/CHANGELOG.md b/rabbitmq/CHANGELOG.md new file mode 100644 index 000000000..c3d2b71a8 --- /dev/null +++ b/rabbitmq/CHANGELOG.md @@ -0,0 +1,189 @@ +rabbitmq Cookbook CHANGELOG +=========================== +This file is used to list changes made in each version of the rabbitmq cookbook. + +v3.4.0 (2014-11-23) +------------------- +- Updated the RuboCop camel case +- Make rabbitmq service restart immediately +- Add sensitive flag for resources that expose passwords in log +- Issue: #153 +- move serverspec v1 tests to use busser-rspec +- Adding switch to make TCP listeners optional +- Update user.rb +- Update default.rb +- Merge branch 'pr-128' +- add serverspec tests for plugin lwrp +- Plugin provider. fixes #141 +- Add test that fails if plugin notifications aren't working properly. + +v3.3.0 (2014-08-28) +------------------- +- Bump default rabbitmq-server version to 3.3.5 +- [COOK-4641] - remove setsid calls in service resource +- Testing updates +- Minor documentation fix re: rabbitmq_policy usage + +v3.2.2 (2014-05-07) +------------------- +- [COOK-2676] - Fixing startup issue when cluster mode is enabled + + +v3.2.0 (2014-04-23) +------------------- +- [COOK-4517] - Add cluster partition handling attribute to the cookbook + + +v3.1.0 (2014-03-27) +------------------- +- [COOK-4459] - added missing dependency package logrotate +- [COOK-4279] - Addition of ssl_opts in rabbitmq.config when web_console_ssl is enabled + + +v3.0.4 (2014-03-19) +------------------- +- [COOK-4431] - RPM / DEB package installs now use the rabbit version you specify +- [COOK-4438] - rabbitmq_policy resource breaks if you use rabbitmq version >= 3.2 + + +v3.0.2 (2014-02-27) +------------------- +- [COOK-4384] Add ChefSpec Custom Matchers for LWRPs + + +v3.0.0 (2014-02-27) +------------------- +[COOK-4369] - use_inline_resources + + +v2.4.2 (2014-02-27) +------------------- +[COOK-4280] Upstart script properly waits until the server is started + + +v2.4.0 (2014-02-14) +------------------- +- [COOK-4050] - Do not force failure in rabbitmq_user +- [COOK-4088] - Update rabbitmq.config for port ranges +- Updating test harness. Fixing style cops + + +v2.3.2 +------ +### Bug +- **[COOK-3678](https://tickets.opscode.com/browse/COOK-3678)** - Fix an issue where a RabbitMQ policy resource with vhost arguments emits unexpected restart notification +- **[COOK-3606](https://tickets.opscode.com/browse/COOK-3606)** - Fix erlang cookie comparison +- **[COOK-3512](https://tickets.opscode.com/browse/COOK-3512)** - Define rabbitmq service on SUSE + +### New Feature +- **[COOK-3538](https://tickets.opscode.com/browse/COOK-3538)** - Configure web management console to use SSL + + +v2.3.0 +------ +### Improvement +- **[COOK-3369](https://tickets.opscode.com/browse/COOK-3369)** - Add SUSE support +- **[COOK-3320](https://tickets.opscode.com/browse/COOK-3320)** - Configure bind and cluster over a specified addr +- **[COOK-3138](https://tickets.opscode.com/browse/COOK-3138)** - Do not log RabbitMQ password +- **[COOK-2803](https://tickets.opscode.com/browse/COOK-2803)** - Bind erlang networking to localhost (attribute-driven) + +v2.2.0 +------ +### Improvement +- Greatly expanded Test Kitchen coverage and platform support +- added support for disabling policies and virtualhosts through attributes +- added support for using with the erlang::esl recipe +- [COOK-2705]: Add ability to change tcp_listen_options in config +- [COOK-2397]: Added upstart support to rabbitmq cookbook +- [COOK-2830]: Use a notify for server restart, instead of defining a new service +- [COOK-3384]: Added ability to change user password +- [COOK-3489]: Add attribute to set open file limit + +### Bug +- [COOK-3011]: Incorrect apt source test causes Chef run to fail on Ubuntu +- [COOK-3438]: RabbitMQ fixes for Fedora 19 + +v2.1.2 +------ +### Improvement +- [COOK-3099]: policy resource should support optional vhost argument + +### Bug + +- [COOK-3078]: rabbitmq password is not quoted or escaped on add_user +- [COOK-3079]: rabbitmq permissions check doesn't match, resulting in non-idempotency + +v2.1.0 +------ +### Bug +- [COOK-2828]: Rabbitmq Clustering doesn't work properly +- [COOK-2975]: rabbitmq has foodcritic failures + +### New Feature +- [COOK-2575]: LWRP for setting policies + +v2.0.0 +------ +- Major v2.0 changes are documented in the README. +- [COOK-2391] - Added support for verify verify_peer and fail_if_no_peer_cert true +- [COOK-2153] - Fix of user LWRP +- [COOK-2180] - Plugin management via node attributes +- [COOK-2201] - Use the proper syntax when using rabbitmq 3.0 instead of 2.x +- [COOK-2210] - User management via node attributes +- [COOK-2211] - Virtualhost management via node attributes +- [COOK-2235] - RabbitMQ bin path isn't necessarily part of PATH for the plugin provider +- [COOK-2392] - correctly configure a rabbitmq cluster +- [COOK-2366] - Default recipe doesn't create mnesia dir +- [COOK-2416] - Add support for clearing tags. + +v1.8.0 +------ +- [COOK-2151] - Add config options for `disk_free_limit` and `vm_memory_high_watermark` via attributes + +v1.7.0 +------ +- [COOK-1850] - oracle linux support +- [COOK-1873] - add `set_user_tag` action to `rabbitmq_user` LWRP +- [COOK-1878] - :immediately action causes clustering to fail +- [COOK-1888] - smartos support + +v1.6.4 +------ +- [COOK-1684] - Unify behavior of debian and rhel clones in the rabbitmq cookbook +- [COOK-1724] - enable using the distro release of rabbitmq instead of the RabbitMQ.org version + +v1.6.2 +------ +- [COOK-1552] - removed rogue single quote from rabbitmq ssl configuration + +v1.6.0 +------ +- [COOK-1496] - explicitly include the apt recipe +- [COOK-1501] - Allow user to enable yum-based installation of rabbitmq via an attribute +- [COOK-1503] - Recipe to enable rabbitmq web management console + +v1.5.0 +------ +This version requires apt cookbook v1.4.4 (reflected in metadata). + +- [COOK-1216] - add amazon linux to RHELish platforms +- [COOK-1217] - specify version, for RHELish platforms +- [COOK-1219] - immediately restart service on config update +- [COOK-1317] - fix installation of old version from ubuntu APT repo +- [COOK-1331] - LWRP for enabling/disabling rabbitmq plugins +- [COOK-1386] - increment rabbitmq version to 2.8.4 +- [COOK-1432] - resolve foodcritic warnings +- [COOK-1438] - add fedora to RHELish platforms + +v1.4.1 +------ +- [COOK-1386] - Bumped version to 2.8.4 +- rabbitmq::default now includes erlang::default + +v1.4.0 +------ +- [COOK-911] - Auto clustering support + +v1.3.2 +------ +- [COOK-585] - manage rabbitmq-server service diff --git a/rabbitmq/CONTRIBUTING.md b/rabbitmq/CONTRIBUTING.md new file mode 100644 index 000000000..3a9989787 --- /dev/null +++ b/rabbitmq/CONTRIBUTING.md @@ -0,0 +1,257 @@ +# Contributing to Opscode Cookbooks + +We are glad you want to contribute to Opscode Cookbooks! The first +step is the desire to improve the project. + +You can find the answers to additional frequently asked questions +[on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute). + +You can find additional information about +[contributing to cookbooks](http://wiki.opscode.com/display/chef/How+to+Contribute+to+Opscode+Cookbooks) +on the wiki as well. + +## Quick-contribute + +* Create an account on our [bug tracker](http://tickets.opscode.com) +* Sign our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) +(keep reading if you're contributing on behalf of your employer) +* Create a ticket for your change on the + [bug tracker](http://tickets.opscode.com) +* Link to your patch as a rebased git branch or pull request from the + ticket +* Resolve the ticket as fixed + +We regularly review contributions and will get back to you if we have +any suggestions or concerns. + +## The Apache License and the CLA/CCLA + +Licensing is very important to open source projects, it helps ensure +the software continues to be available under the terms that the author +desired. Chef uses the Apache 2.0 license to strike a balance between +open contribution and allowing you to use the software however you +would like to. + +The license tells you what rights you have that are provided by the +copyright holder. It is important that the contributor fully +understands what rights they are licensing and agrees to them. +Sometimes the copyright holder isn't the contributor, most often when +the contributor is doing work for a company. + +To make a good faith effort to ensure these criteria are met, Opscode +requires a Contributor License Agreement (CLA) or a Corporate +Contributor License Agreement (CCLA) for all contributions. This is +without exception due to some matters not being related to copyright +and to avoid having to continually check with our lawyers about small +patches. + +It only takes a few minutes to complete a CLA, and you retain the +copyright to your contribution. + +You can complete our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L). +If you're contributing on behalf of your employer, have your employer +fill out our +[Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) +instead. + +## Ticket Tracker (JIRA) + +The [ticket tracker](http://tickets.opscode.com) is the most important +documentation for the code base. It provides significant historical +information, such as: + +* Which release a bug fix is included in +* Discussion regarding the design and merits of features +* Error output to aid in finding similar bugs + +Each ticket should aim to fix one bug or add one feature. + +## Using git + +You can get a quick copy of the repository for this cookbook by +running `git clone +git://github.com/opscode-coobkooks/COOKBOOKNAME.git`. + +For collaboration purposes, it is best if you create a Github account +and fork the repository to your own account. Once you do this you will +be able to push your changes to your Github repository for others to +see and use. + +If you have another repository in your GitHub account named the same +as the cookbook, we suggest you suffix the repository with -cookbook. + +### Branches and Commits + +You should submit your patch as a git branch named after the ticket, +such as COOK-1337. This is called a _topic branch_ and allows users to +associate a branch of code with the ticket. + +It is a best practice to have your commit message have a _summary +line_ that includes the ticket number, followed by an empty line and +then a brief description of the commit. This also helps other +contributors understand the purpose of changes to the code. + + [COOK-1757] - platform_family and style + + * use platform_family for platform checking + * update notifies syntax to "resource_type[resource_name]" instead of + resources() lookup + * COOK-692 - delete config files dropped off by packages in conf.d + * dropped debian 4 support because all other platforms have the same + values, and it is older than "old stable" debian release + +Remember that not all users use Chef in the same way or on the same +operating systems as you, so it is helpful to be clear about your use +case and change so they can understand it even when it doesn't apply +to them. + +### Github and Pull Requests + +All of Opscode's open source cookbook projects are available on +[Github](http://www.github.com/opscode-cookbooks). + +We don't require you to use Github, and we will even take patch diffs +attached to tickets on the tracker. However Github has a lot of +convenient features, such as being able to see a diff of changes +between a pull request and the main repository quickly without +downloading the branch. + +If you do choose to use a pull request, please provide a link to the +pull request from the ticket __and__ a link to the ticket from the +pull request. Because pull requests only have two states, open and +closed, we can't easily filter pull requests that are waiting for a +reply from the author for various reasons. + +### More information + +Additional help with git is available on the +[Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git) +wiki page. + +## Functional and Unit Tests + +This cookbook is set up to run tests under +[Opscode's test-kitchen](https://github.com/opscode/test-kitchen). It +uses minitest-chef to run integration tests after the node has been +converged to verify that the state of the node. + +Test kitchen should run completely without exception using the default +[baseboxes provided by Opscode](https://github.com/opscode/bento). +Because Test Kitchen creates VirtualBox machines and runs through +every configuration in the Kitchenfile, it may take some time for +these tests to complete. + +If your changes are only for a specific recipe, run only its +configuration with Test Kitchen. If you are adding a new recipe, or +other functionality such as a LWRP or definition, please add +appropriate tests and ensure they run with Test Kitchen. + +If any don't pass, investigate them before submitting your patch. + +Any new feature should have unit tests included with the patch with +good code coverage to help protect it from future changes. Similarly, +patches that fix a bug or regression should have a _regression test_. +Simply put, this is a test that would fail without your patch but +passes with it. The goal is to ensure this bug doesn't regress in the +future. Consider a regular expression that doesn't match a certain +pattern that it should, so you provide a patch and a test to ensure +that the part of the code that uses this regular expression works as +expected. Later another contributor may modify this regular expression +in a way that breaks your use cases. The test you wrote will fail, +signalling to them to research your ticket and use case and accounting +for it. + +If you need help writing tests, please ask on the Chef Developer's +mailing list, or the #chef-hacking IRC channel. + +## Code Review + +Opscode regularly reviews code contributions and provides suggestions +for improvement in the code itself or the implementation. + +We find contributions by searching the ticket tracker for _resolved_ +tickets with a status of _fixed_. If we have feedback we will reopen +the ticket and you should resolve it again when you've made the +changes or have a response to our feedback. When we believe the patch +is ready to be merged, we will tag the _Code Reviewed_ field with +_Reviewed_. + +Depending on the project, these tickets are then merged within a week +or two, depending on the current release cycle. + +## Release Cycle + +The versioning for Opscode Cookbook projects is X.Y.Z. + +* X is a major release, which may not be fully compatible with prior + major releases +* Y is a minor release, which adds both new features and bug fixes +* Z is a patch release, which adds just bug fixes + +A released version of a cookbook will end in an even number, e.g. +"1.2.4" or "0.8.0". When development for the next version of the +cookbook begins, the "Z" patch number is incremented to the next odd +number, however the next release of the cookbook may be a major or +minor incrementing version. + +Releases of Opscode's cookbooks are usually announced on the Chef user +mailing list. Releases of several cookbooks may be batched together +and announced on the [Opscode Blog](http://www.opscode.com/blog). + +## Working with the community + +These resources will help you learn more about Chef and connect to +other members of the Chef community: + +* [chef](http://lists.opscode.com/sympa/info/chef) and + [chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing + lists +* #chef and #chef-hacking IRC channels on irc.freenode.net +* [Community Cookbook site](http://community.opscode.com) +* [Chef wiki](http://wiki.opscode.com/display/chef) +* Opscode Chef [product page](http://www.opscode.com/chef) + + +## Cookbook Contribution Do's and Don't's + +Please do include tests for your contribution. If you need help, ask +on the +[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev) +or the +[#chef-hacking IRC channel](http://community.opscode.com/chat/chef-hacking). +Not all platforms that a cookbook supports may be supported by Test +Kitchen. Please provide evidence of testing your contribution if it +isn't trivial so we don't have to duplicate effort in testing. Chef +10.14+ "doc" formatted output is sufficient. + +Please do indicate new platform (families) or platform versions in the +commit message, and update the relevant ticket. + +If a contribution adds new platforms or platform versions, indicate +such in the body of the commit message(s), and update the relevant +COOK ticket. When writing commit messages, it is helpful for others if +you indicate the COOK ticket. For example: + + git commit -m '[COOK-1041] - Updated pool resource to correctly + delete.' + +Please do use [foodcritic](http://acrmp.github.com/foodcritic) to +lint-check the cookbook. Except FC007, it should pass all correctness +rules. FC007 is okay as long as the dependent cookbooks are *required* +for the default behavior of the cookbook, such as to support an +uncommon platform, secondary recipe, etc. + +Please do ensure that your changes do not break or modify behavior for +other platforms supported by the cookbook. For example if your changes +are for Debian, make sure that they do not break on CentOS. + +Please do not modify the version number in the metadata.rb, Opscode +will select the appropriate version based on the release cycle +information above. + +Please do not update the CHANGELOG.md for a new version. Not all +changes to a cookbook may be merged and released in the same versions. +Opscode will update the CHANGELOG.md when releasing a new version of +the cookbook. diff --git a/rabbitmq/Gemfile b/rabbitmq/Gemfile new file mode 100644 index 000000000..ff1100d70 --- /dev/null +++ b/rabbitmq/Gemfile @@ -0,0 +1,38 @@ +source 'https://rubygems.org' + +group :lint do + gem 'foodcritic', '~> 3.0' + gem 'rubocop', '~> 0.18' + gem 'rainbow', '< 2.0' +end + +group :unit do + gem 'berkshelf', '~> 3.0.0.beta6' + gem 'chefspec', '~> 3.1' +end + +group :kitchen_common do + gem 'test-kitchen', '~> 1.2' +end + +group :kitchen_vagrant do + gem 'kitchen-vagrant', '~> 0.11' +end + +group :kitchen_cloud do + gem 'kitchen-digitalocean' + gem 'kitchen-ec2' +end + +group :development do + gem 'ruby_gntp' + gem 'growl' + gem 'rb-fsevent' + gem 'guard', '~> 2.4' + gem 'guard-kitchen' + gem 'guard-foodcritic' + gem 'guard-rspec' + gem 'guard-rubocop' + gem 'rake' + gem 'stove' +end diff --git a/rabbitmq/Guardfile b/rabbitmq/Guardfile new file mode 100644 index 000000000..054cdabf0 --- /dev/null +++ b/rabbitmq/Guardfile @@ -0,0 +1,35 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +# guard 'kitchen' do +# watch(%r{test/.+}) +# watch(%r{^recipes/(.+)\.rb$}) +# watch(%r{^attributes/(.+)\.rb$}) +# watch(%r{^files/(.+)}) +# watch(%r{^templates/(.+)}) +# watch(%r{^providers/(.+)\.rb}) +# watch(%r{^resources/(.+)\.rb}) +# end + +guard 'foodcritic', :cookbook_paths => '.', :all_on_start => false do + watch(%r{attributes/.+\.rb$}) + watch(%r{providers/.+\.rb$}) + watch(%r{recipes/.+\.rb$}) + watch(%r{resources/.+\.rb$}) + watch('metadata.rb') +end + +guard 'rubocop', :all_on_start => false do + watch(%r{attributes/.+\.rb$}) + watch(%r{providers/.+\.rb$}) + watch(%r{recipes/.+\.rb$}) + watch(%r{resources/.+\.rb$}) + watch('metadata.rb') +end + +guard :rspec, :cmd => 'bundle exec rspec', :all_on_start => false, :notification => false do + watch(%r{^libraries/(.+)\.rb$}) + watch(%r{^spec/(.+)_spec\.rb$}) + watch(%r{^(recipes)/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } +end diff --git a/rabbitmq/LICENSE b/rabbitmq/LICENSE new file mode 100644 index 000000000..11069edd7 --- /dev/null +++ b/rabbitmq/LICENSE @@ -0,0 +1,201 @@ + 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/rabbitmq/README.md b/rabbitmq/README.md new file mode 100644 index 000000000..dfcafeec2 --- /dev/null +++ b/rabbitmq/README.md @@ -0,0 +1,176 @@ +rabbitmq Cookbook +================= +This is a cookbook for managing RabbitMQ with Chef. It is intended for 2.6.1 or later releases. + +**Version 2.0 Changes** + +The 2.0 release of the cookbook defaults to using the latest version available from RabbitMQ.com via direct download of the package. This was done to simplify the installation options to either distro package or direct download. The attributes `use_apt` and `use_yum` have been removed as have the `apt` and `yum` cookbook dependencies. The user LWRP action `:set_user_tags` was changed to `:set_tags` for consistency with other actions. + + +Requirements +------------ +This cookbook depends on the `erlang` cookbook. + +Please refer to the [TESTING file](TESTING.md) to see the currently (and passing) tested platforms. The release was tested with (rabbitmq.com/distro version): +- CentOS 5.9: 3.1.5 (distro release unsupported) +- CentOS 6.4: 3.1.5/2.6.1 (no lwrps support) +- Fedora 18: 3.1.5 (distro release unsupported) +- Ubuntu 10.04: 3.1.5 (distro release unsupported) +- Ubuntu 12.04: 3.1.5/2.7.1 (no lwrps support) +- Ubuntu 13.04: 3.1.5/3.0.2 + + +Recipes +------- +### default +Installs `rabbitmq-server` from RabbitMQ.com via direct download of the installation package or using the distribution version. Depending on your distribution, the provided version may be quite old so they are disabled by default. If you want to use the distro version, set the attribute `['rabbitmq']['use_distro_version']` to `true`. You may override the download URL attribute `['rabbitmq']['package']` if you wish to use a local mirror. + +The cluster recipe is now combined with the default and will now auto-cluster. Set the `['rabbitmq']['cluster']` attribute to `true`, `['rabbitmq']['cluster_disk_nodes']` array of `node@host` strings that describe which you want to be disk nodes and then set an alphanumeric string for the `erlang_cookie`. + +To enable SSL turn `ssl` to `true` and set the paths to your cacert, cert and key files. + +### mgmt_console +Installs the `rabbitmq_management` and `rabbitmq_management_visualiser` plugins. +To use https connection to management console, turn `['rabbitmq']['web_console_ssl']` to true. The SSL port for web management console can be configured by setting attribute `['rabbitmq']['web_console_ssl_port']`, whose default value is 15671. + +### plugin_management +Enables any plugins listed in the `node['rabbitmq']['enabled_plugins']` and disables any listed in `node['rabbitmq'][disabled_plugins']` attributes. + +### policy_management +Enables any policies listed in the `node['rabbitmq'][policies]` and disables any listed in `node['rabbitmq'][disabled_policies]` attributes. + +### user_management +Enables any users listed in the `node['rabbitmq']['enabled_users]` and disables any listed in `node['rabbitmq'][disabled_users]` attributes. + +### virtualhost_management +Enables any vhosts listed in the `node['rabbitmq'][virtualhosts]` and disables any listed in `node['rabbitmq'][disabled_virtualhosts]` attributes. + + +Resources/Providers +------------------- +There are 4 LWRPs for interacting with RabbitMQ. + +### plugin +Enables or disables a rabbitmq plugin. Plugins are not supported for releases prior to 2.7.0. + +- `:enable` enables a `plugin` +- `:disable` disables a `plugin` + +#### Examples +```ruby +rabbitmq_plugin "rabbitmq_stomp" do + action :enable +end +``` + +```ruby +rabbitmq_plugin "rabbitmq_shovel" do + action :disable +end +``` + +### policy +sets or clears a rabbitmq policy. + +- `:set` sets a `policy` +- `:clear` clears a `policy` +- `:list` lists `policy`s + +#### Examples +```ruby +rabbitmq_policy "ha-all" do + pattern "^(?!amq\\.).*" + params ({"ha-mode"=>"all"}) + priority 1 + action :set +end +``` + +```ruby +rabbitmq_policy "ha-all" do + action :clear +end +``` + +### user +Adds and deletes users, fairly simplistic permissions management. + +- `:add` adds a `user` with a `password` +- `:delete` deletes a `user` +- `:set_permissions` sets the `permissions` for a `user`, `vhost` is optional +- `:clear_permissions` clears the permissions for a `user` +- `:set_tags` set the tags on a user +- `:clear_tags` clear any tags on a user +- `:change_password` set the `password` for a `user` + +#### Examples +```ruby +rabbitmq_user "guest" do + action :delete +end +``` + +```ruby +rabbitmq_user "nova" do + password "sekret" + action :add +end +``` + +```ruby +rabbitmq_user "nova" do + vhost "/nova" + permissions ".* .* .*" + action :set_permissions +end +``` + +```ruby +rabbitmq_user "joe" do + tag "admin,lead" + action :set_tags +end +``` + +### vhost +Adds and deletes vhosts. + +- `:add` adds a `vhost` +- `:delete` deletes a `vhost` + +#### Examples +``` ruby +rabbitmq_vhost "/nova" do + action :add +end +``` + + +Limitations +----------- +For an already running cluster, these actions still require manual intervention: +- changing the :erlang_cookie +- turning :cluster from true to false + + +License & Authors +----------------- +- Author:: Benjamin Black +- Author:: Daniel DeLeo +- Author:: Matt Ray () + +```text +Copyright (c) 2009-2013, Opscode, Inc. + +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/rabbitmq/Rakefile b/rabbitmq/Rakefile new file mode 100644 index 000000000..c63593ea2 --- /dev/null +++ b/rabbitmq/Rakefile @@ -0,0 +1,62 @@ +require 'rspec/core/rake_task' +require 'rubocop/rake_task' +require 'foodcritic' +require 'kitchen' + +# Style tests. Rubocop and Foodcritic +namespace :style do + desc 'Run Ruby style checks' + RuboCop::RakeTask.new(:ruby) + + desc 'Run Chef style checks' + FoodCritic::Rake::LintTask.new(:chef) do |t| + t.options = { + :fail_tags => ['any'], + :tags => [ + '~FC005', + '~FC023' + ] + } + end +end + +desc 'Run all style checks' +task :style => ['style:chef', 'style:ruby'] + +# Rspec and ChefSpec +desc 'Run ChefSpec examples' +RSpec::Core::RakeTask.new(:spec) + +# Integration tests. Kitchen.ci +namespace :integration do + desc 'Run Test Kitchen with Vagrant' + task :vagrant do + Kitchen.logger = Kitchen.default_file_logger + Kitchen::Config.new.instances.each do |instance| + instance.test(:always) + end + end + + desc 'Run Test Kitchen with cloud plugins' + task :cloud do + run_kitchen = true + if ENV['TRAVIS'] == 'true' && ENV['TRAVIS_PULL_REQUEST'] != 'false' + run_kitchen = false + end + + if run_kitchen + Kitchen.logger = Kitchen.default_file_logger + @loader = Kitchen::Loader::YAML.new(:project_config => './.kitchen.cloud.yml') + config = Kitchen::Config.new(:loader => @loader) + config.instances.each do |instance| + instance.test(:always) + end + end + end +end + +desc 'Run all tests on Travis' +task :travis => ['style', 'spec', 'integration:cloud'] + +# Default +task :default => ['style', 'spec', 'integration:vagrant'] diff --git a/rabbitmq/TESTING.md b/rabbitmq/TESTING.md new file mode 100644 index 000000000..5b20bb830 --- /dev/null +++ b/rabbitmq/TESTING.md @@ -0,0 +1,187 @@ +TESTING doc +======================== + +Bundler +------- +A ruby environment with Bundler installed is a prerequisite for using +the testing harness shipped with this cookbook. At the time of this +writing, it works with Ruby 2.0 and Bundler 1.5.3. All programs +involved, with the exception of Vagrant, can be installed by cd'ing +into the parent directory of this cookbook and running "bundle install" + +Rakefile +-------- +The Rakefile ships with a number of tasks, each of which can be ran +individually, or in groups. Typing "rake" by itself will perform style +checks with Rubocop and Foodcritic, ChefSpec with rspec, and +integration with Test Kitchen using the Vagrant driver by +default.Alternatively, integration tests can be ran with Test Kitchen +cloud drivers. + +``` +$ rake -T +rake integration:cloud # Run Test Kitchen with cloud plugins +rake integration:vagrant # Run Test Kitchen with Vagrant +rake spec # Run ChefSpec examples +rake style # Run all style checks +rake style:chef # Lint Chef cookbooks +rake style:ruby # Run Ruby style checks +rake travis # Run all tests on Travis +``` + +Style Testing +------------- +Ruby style tests can be performed by Rubocop by issuing either +``` +bundle exec rubocop +``` +or +``` +rake style:ruby +``` + +Chef style tests can be performed with Foodcritic by issuing either +``` +bundle exec foodcritic +``` +or +``` +rake style:chef +``` + +Spec Testing +------------- +Unit testing is done by running Rspec examples. Rspec will test any +libraries, then test recipes using ChefSpec. This works by compiling a +recipe (but not converging it), and allowing the user to make +assertions about the resource_collection. + +Integration Testing +------------------- +Integration testing is performed by Test Kitchen. Test Kitchen will +use either the Vagrant driver or various cloud drivers to instantiate +machines and apply cookbooks. After a successful converge, tests are +uploaded and ran out of band of Chef. Tests should be designed to +ensure that a recipe has accomplished its goal. + +Integration Testing using Vagrant +--------------------------------- +Integration tests can be performed on a local workstation using +Virtualbox or VMWare. Detailed instructions for setting this up can be +found at the [Bento](https://github.com/opscode/bento) project web site. + +Integration tests using Vagrant can be performed with either +``` +bundle exec kitchen test +``` +or +``` +rake integration:vagrant +``` + +Integration Testing using Cloud providers +----------------------------------------- +Integration tests can be performed on cloud providers using +Test Kitchen plugins. This cookbook ships a ```.kitchen.cloud.yml``` +that references environmental variables present in the shell that +```kitchen test``` is ran from. These usually contain authentication +tokens for driving IaaS APIs, as well as the paths to ssh private keys +needed for Test Kitchen log into them after they've been created. + +Examples of environment variables being set in ```~/.bash_profile```: +``` +# digital_ocean +export DIGITAL_OCEAN_CLIENT_ID='your_bits_here' +export DIGITAL_OCEAN_API_KEY='your_bits_here' +export DIGITAL_OCEAN_SSH_KEY_IDS='your_bits_here' + +# aws +export AWS_ACCESS_KEY_ID='your_bits_here' +export AWS_SECRET_ACCESS_KEY='your_bits_here' +export AWS_KEYPAIR_NAME='your_bits_here' + +# joyent +export SDC_CLI_ACCOUNT='your_bits_here' +export SDC_CLI_IDENTITY='your_bits_here' +export SDC_CLI_KEY_ID='your_bits_here' +``` + +Integration tests using cloud drivers can be performed with either +``` +export KITCHEN_YAML=.kitchen.cloud.yml +bundle exec kitchen test +``` +or +``` +rake integration:cloud +``` + +Digital Ocean Hint +------------------ +At the time of this writing, you cannot find the numerical values +needed for your SSH_KEY_IDS from the GUI. Instead, you will need to +access the API from the command line. + + curl -L 'https://api.digitalocean.com/ssh_keys/?client_id=your_bits_here&api_key=your_bits_here' + +Words about .travis.yml +----------------------- +In order for Travis to perform integration tests on public cloud +providers, two major things need to happen. First, the environment +variables referenced by ```.kitchen.cloud.yml``` need to be made +available. Second, the private half of the ssh keys needed to log into +machines need to be dropped off on the machine. + +The first part is straight forward. The travis gem can encrypt +environment variables against the public key on the Travis repository +and add them to the .travis.yml. + +``` +gem install travis +travis encrypt AWS_ACCESS_KEY_ID='your_bits_here' --add +travis encrypt AWS_SECRET_ACCESS_'your_bits_here' --add +travis encrypt AWS_KEYPAIR_NAME='your_bits_here' --add +travis encrypt EC2_SSH_KEY_PATH='~/.ssh/id_ec2.pem' --add + +travis encrypt DIGITAL_OCEAN_CLIENT_ID='your_bits_here' --add +travis encrypt DIGITAL_OCEAN_API_KEY='your_bits_here' --add +travis encrypt DIGITAL_OCEAN_SSH_KEY_IDS='your_bits_here' --add +travis encrypt DIGITAL_OCEAN_SSH_KEY_PATH='~/.ssh/id_do.pem' --add +``` + +The second part is a little more complicated. Travis ENV variables are +restricted to 90 bytes, and will not fit an entire SSH key. This can +be worked around by breaking them up into 90 byte chunks, stashing +them into ENV variables, then digging them out in the +```before_install``` section of .travis.yml + +Here is an AWK script to do the encoding. +``` +base64 ~/.ssh/travisci_cook_digitalocean.pem | \ +awk '{ + j=0; + for( i=1; i> ~/.ssh/id_do.base64 +- cat ~/.ssh/id_do.base64 | tr -d ' ' | base64 --decode > ~/.ssh/id_do.pem + - echo -n $EC2_KEY_CHUNK_{0..30} >> ~/.ssh/id_ec2.base64 + - cat ~/.ssh/id_ec2.base64 | tr -d ' ' | base64 --decode > ~/.ssh/id_ec2.pem +``` + diff --git a/rabbitmq/attributes/default.rb b/rabbitmq/attributes/default.rb new file mode 100644 index 000000000..4a6b81603 --- /dev/null +++ b/rabbitmq/attributes/default.rb @@ -0,0 +1,102 @@ +# Latest RabbitMQ.com version to install +default['rabbitmq']['version'] = '3.3.5' +# The distro versions may be more stable and have back-ported patches +default['rabbitmq']['use_distro_version'] = false + +# being nil, the rabbitmq defaults will be used +default['rabbitmq']['nodename'] = nil +default['rabbitmq']['address'] = nil +default['rabbitmq']['port'] = nil +default['rabbitmq']['config'] = nil +default['rabbitmq']['logdir'] = nil +default['rabbitmq']['mnesiadir'] = '/var/lib/rabbitmq/mnesia' +default['rabbitmq']['service_name'] = 'rabbitmq-server' + +# config file location +# http://www.rabbitmq.com/configure.html#define-environment-variables +# "The .config extension is automatically appended by the Erlang runtime." +default['rabbitmq']['config_root'] = '/etc/rabbitmq' +default['rabbitmq']['config'] = '/etc/rabbitmq/rabbitmq' +default['rabbitmq']['erlang_cookie_path'] = '/var/lib/rabbitmq/.erlang.cookie' + +# rabbitmq.config defaults +default['rabbitmq']['default_user'] = 'guest' +default['rabbitmq']['default_pass'] = 'guest' + +# Erlang kernel application options +# See http://www.erlang.org/doc/man/kernel_app.html +default['rabbitmq']['kernel']['inet_dist_listen_min'] = nil +default['rabbitmq']['kernel']['inet_dist_listen_max'] = nil + +# Tell Erlang what IP to bind to +default['rabbitmq']['kernel']['inet_dist_use_interface'] = nil + +# clustering +default['rabbitmq']['cluster'] = false +default['rabbitmq']['cluster_disk_nodes'] = [] +default['rabbitmq']['erlang_cookie'] = 'AnyAlphaNumericStringWillDo' +default['rabbitmq']['cluster_partition_handling'] = 'ignore' + +# resource usage +default['rabbitmq']['disk_free_limit_relative'] = nil +default['rabbitmq']['vm_memory_high_watermark'] = nil +default['rabbitmq']['max_file_descriptors'] = 1024 +default['rabbitmq']['open_file_limit'] = nil + +# job control +default['rabbitmq']['job_control'] = 'initd' + +# ssl +default['rabbitmq']['ssl'] = false +default['rabbitmq']['ssl_port'] = 5671 +default['rabbitmq']['ssl_cacert'] = '/path/to/cacert.pem' +default['rabbitmq']['ssl_cert'] = '/path/to/cert.pem' +default['rabbitmq']['ssl_key'] = '/path/to/key.pem' +default['rabbitmq']['ssl_verify'] = 'verify_none' +default['rabbitmq']['ssl_fail_if_no_peer_cert'] = false +default['rabbitmq']['web_console_ssl'] = false +default['rabbitmq']['web_console_ssl_port'] = 15_671 + +# tcp listen options +default['rabbitmq']['tcp_listen'] = true +default['rabbitmq']['tcp_listen_packet'] = 'raw' +default['rabbitmq']['tcp_listen_reuseaddr'] = true +default['rabbitmq']['tcp_listen_backlog'] = 128 +default['rabbitmq']['tcp_listen_nodelay'] = true +default['rabbitmq']['tcp_listen_exit_on_close'] = false +default['rabbitmq']['tcp_listen_keepalive'] = false + +# virtualhosts +default['rabbitmq']['virtualhosts'] = [] +default['rabbitmq']['disabled_virtualhosts'] = [] + +# users +default['rabbitmq']['enabled_users'] = + [{ :name => 'guest', :password => 'guest', :rights => + [{ :vhost => nil, :conf => '.*', :write => '.*', :read => '.*' }] + }] +default['rabbitmq']['disabled_users'] = [] + +# plugins +default['rabbitmq']['enabled_plugins'] = [] +default['rabbitmq']['disabled_plugins'] = [] + +# platform specific settings +case node['platform_family'] +when 'smartos' + default['rabbitmq']['service_name'] = 'rabbitmq' + default['rabbitmq']['config_root'] = '/opt/local/etc/rabbitmq' + default['rabbitmq']['config'] = '/opt/local/etc/rabbitmq/rabbitmq' + default['rabbitmq']['erlang_cookie_path'] = '/var/db/rabbitmq/.erlang.cookie' +end + +# Example HA policies +default['rabbitmq']['policies']['ha-all']['pattern'] = '^(?!amq\\.).*' +default['rabbitmq']['policies']['ha-all']['params'] = { 'ha-mode' => 'all' } +default['rabbitmq']['policies']['ha-all']['priority'] = 0 + +default['rabbitmq']['policies']['ha-two']['pattern'] = "^two\." +default['rabbitmq']['policies']['ha-two']['params'] = { 'ha-mode' => 'exactly', 'ha-params' => 2 } +default['rabbitmq']['policies']['ha-two']['priority'] = 1 + +default['rabbitmq']['disabled_policies'] = [] diff --git a/rabbitmq/libraries/default.rb b/rabbitmq/libraries/default.rb new file mode 100644 index 000000000..e93bb2590 --- /dev/null +++ b/rabbitmq/libraries/default.rb @@ -0,0 +1,42 @@ +# +# Cookbook Name:: rabbitmq +# Library:: default +# Author:: Jake Davis () +# +# 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. +# + +module Opscode + # module rabbit + module RabbitMQ + # This method does some of the yuckiness of formatting parameters properly + # for rendering into the rabbit.config template. + def format_kernel_parameters + rendered = [] + kernel = node['rabbitmq']['kernel'].dup + + # This parameter is special and needs commas instead of periods. + rendered << "{inet_dist_use_interface, {#{kernel[:inet_dist_use_interface].gsub(/\./, ',')}}}" if kernel[:inet_dist_use_interface] + kernel.delete(:inet_dist_use_interface) + + # Otherwise, we can just render it nicely as Erlang wants. This + # theoretically opens the door for arbitrary kernel_app parameters to be + # declared. + kernel.select { |_k, v| !v.nil? }.each_pair do |param, val| + rendered << "{#{param}, #{val}}" + end + + rendered.each { |r| r.prepend(' ') }.join(",\n") + end + end +end diff --git a/rabbitmq/libraries/matchers.rb b/rabbitmq/libraries/matchers.rb new file mode 100644 index 000000000..26a60bc68 --- /dev/null +++ b/rabbitmq/libraries/matchers.rb @@ -0,0 +1,57 @@ +if defined?(ChefSpec) + def add_rabbitmq_user(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :add, resource_name) + end + + def delete_rabbitmq_user(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :delete, resource_name) + end + + def set_permissions_rabbitmq_user(resource_name) # rubocop:disable AccessorMethodName + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :set_permissions, resource_name) + end + + def clear_permissions_rabbitmq_user(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :clear_permissions, resource_name) + end + + def set_tags_rabbitmq_user(resource_name) # rubocop:disable AccessorMethodName + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :set_tags, resource_name) + end + + def clear_tags_rabbitmq_user(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :clear_tags, resource_name) + end + + def change_password_rabbitmq_user(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_user, :change_password, resource_name) + end + + def add_rabbitmq_vhost(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_vhost, :add, resource_name) + end + + def delete_rabbitmq_vhost(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_vhost, :delete, resource_name) + end + + def set_rabbitmq_policy(resource_name) # rubocop:disable AccessorMethodName + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_policy, :set, resource_name) + end + + def clear_rabbitmq_policy(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_policy, :clear, resource_name) + end + + def list_rabbitmq_policy(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_policy, :list, resource_name) + end + + def enable_rabbitmq_plugin(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_plugin, :enable, resource_name) + end + + def disable_rabbitmq_plugin(resource_name) + ChefSpec::Matchers::ResourceMatcher.new(:rabbitmq_plugin, :disable, resource_name) + end +end diff --git a/rabbitmq/metadata.rb b/rabbitmq/metadata.rb new file mode 100644 index 000000000..b25a397d4 --- /dev/null +++ b/rabbitmq/metadata.rb @@ -0,0 +1,110 @@ +name 'rabbitmq' +maintainer 'Opscode, Inc.' +maintainer_email 'cookbooks@opscode.com' +license 'Apache 2.0' +description 'Installs and configures RabbitMQ server' +version '3.4.0' +recipe 'rabbitmq', 'Install and configure RabbitMQ' +recipe 'rabbitmq::cluster', 'Set up RabbitMQ clustering.' +recipe 'rabbitmq::plugin_management', 'Manage plugins with node attributes' +recipe 'rabbitmq::virtualhost_management', 'Manage virtualhost with node attributes' +recipe 'rabbitmq::user_management', 'Manage users with node attributes' +depends 'erlang', '>= 0.9' + +supports 'debian' +supports 'ubuntu' +supports 'redhat' +supports 'centos' +supports 'scientific' +supports 'amazon' +supports 'oracle' +supports 'smartos' +supports 'suse' + +attribute 'rabbitmq', + :display_name => 'RabbitMQ', + :description => 'Hash of RabbitMQ attributes', + :type => 'hash' + +attribute 'rabbitmq/nodename', + :display_name => 'RabbitMQ Erlang node name', + :description => 'The Erlang node name for this server.', + :default => "node['hostname']" + +attribute 'rabbitmq/address', + :display_name => 'RabbitMQ server IP address', + :description => 'IP address to bind.' + +attribute 'rabbitmq/port', + :display_name => 'RabbitMQ server port', + :description => 'TCP port to bind.' + +attribute 'rabbitmq/config', + :display_name => 'RabbitMQ config file to load', + :description => 'Path to the rabbitmq.config file, if any.' + +attribute 'rabbitmq/logdir', + :display_name => 'RabbitMQ log directory', + :description => 'Path to the directory for log files.' + +attribute 'rabbitmq/mnesiadir', + :display_name => 'RabbitMQ Mnesia database directory', + :description => 'Path to the directory for Mnesia database files.' + +attribute 'rabbitmq/cluster', + :display_name => 'RabbitMQ clustering', + :description => 'Whether to activate clustering.', + :default => 'no' + +attribute 'rabbitmq/cluster_config', + :display_name => 'RabbitMQ clustering configuration file', + :description => 'Path to the clustering configuration file, if cluster is yes.', + :default => '/etc/rabbitmq/rabbitmq_cluster.config' + +attribute 'rabbitmq/cluster_disk_nodes', + :display_name => 'RabbitMQ cluster disk nodes', + :description => 'Array of member Erlang nodenames for the disk-based storage nodes in the cluster.', + :default => [], + :type => 'array' + +attribute 'rabbitmq/erlang_cookie', + :display_name => 'RabbitMQ Erlang cookie', + :description => 'Access cookie for clustering nodes. There is no default.' + +attribute 'rabbitmq/virtualhosts', + :display_name => 'Virtualhosts on rabbitmq instance', + :description => 'List all virtualhosts that will exist', + :default => [], + :type => 'array' + +attribute 'rabbitmq/enabled_users', + :display_name => 'Users and their rights on rabbitmq instance', + :description => 'Users and description of their rights', + :default => [{ :name => 'guest', :password => 'guest', :rights => [{ :vhost => nil, :conf => '.*', :write => '.*', :read => '.*' }] }], + :type => 'array' + +attribute 'rabbitmq/disabled_users', + :display_name => 'Disabled users', + :description => 'List all users that will be deactivated', + :default => [], + :type => 'array' + +attribute 'rabbitmq/enabled_plugins', + :display_name => 'Enabled plugins', + :description => 'List all plugins that will be activated', + :default => [], + :type => 'array' + +attribute 'rabbitmq/disabled_plugins', + :display_name => 'Disabled plugins', + :description => 'List all plugins that will be deactivated', + :default => [], + :type => 'array' + +attribute 'rabbitmq/local_erl_networking', + :display_name => 'Local Erlang networking', + :description => 'Bind erlang networking to localhost' + +attribute 'rabbitmq/erl_networking_bind_address', + :display_name => 'Erl Networking Bind Address', + :description => 'Bind Rabbit and erlang networking to an address' diff --git a/rabbitmq/providers/plugin.rb b/rabbitmq/providers/plugin.rb new file mode 100644 index 000000000..bbce9defd --- /dev/null +++ b/rabbitmq/providers/plugin.rb @@ -0,0 +1,57 @@ +# +# Cookbook Name:: rabbitmq +# Provider:: plugin +# +# Copyright 2012-2013, Opscode, Inc. +# +# 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. +# + +def plugins_bin_path(return_array = false) + path = ENV.fetch('PATH') + ':/usr/lib/rabbitmq/bin' + return_array ? path.split(':') : path +end + +def plugin_enabled?(name) + cmdstr = "rabbitmq-plugins list -e '#{name}\\b'" + cmd = Mixlib::ShellOut.new(cmdstr) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.environment['PATH'] = plugins_bin_path + cmd.run_command + Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmdstr}" + Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmd.stdout}" + cmd.error! + cmd.stdout =~ /\b#{name}\b/ +end + +use_inline_resources + +action :enable do + unless plugin_enabled?(new_resource.plugin) + execute "rabbitmq-plugins enable #{new_resource.plugin}" do + Chef::Log.info "Enabling RabbitMQ plugin '#{new_resource.plugin}'." + path plugins_bin_path(true) + new_resource.updated_by_last_action(true) + end + end +end + +action :disable do + if plugin_enabled?(new_resource.plugin) + execute "rabbitmq-plugins disable #{new_resource.plugin}" do + Chef::Log.info "Disabling RabbitMQ plugin '#{new_resource.plugin}'." + path plugins_bin_path(true) + new_resource.updated_by_last_action(true) + end + end +end diff --git a/rabbitmq/providers/policy.rb b/rabbitmq/providers/policy.rb new file mode 100644 index 000000000..34d6ea976 --- /dev/null +++ b/rabbitmq/providers/policy.rb @@ -0,0 +1,92 @@ +# +# Cookbook Name:: rabbitmq +# Provider:: policy +# +# Author: Robert Choi +# Copyright 2013 by Robert Choi +# +# 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. +# + +require 'shellwords' + +def policy_exists?(vhost, name) + cmd = 'rabbitmqctl list_policies' + cmd << " -p #{Shellwords.escape vhost}" unless vhost.nil? + cmd << " |grep '#{name}\\b'" + + cmd = Mixlib::ShellOut.new(cmd) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.run_command + begin + cmd.error! + true + rescue + false + end +end + +action :set do + unless policy_exists?(new_resource.vhost, new_resource.policy) + cmd = 'rabbitmqctl set_policy' + cmd << " -p #{new_resource.vhost}" unless new_resource.vhost.nil? + cmd << " #{new_resource.policy}" + cmd << " \"#{new_resource.pattern}\"" + cmd << " '{" + + first_param = true + new_resource.params.each do |key, value| + cmd << ',' unless first_param + + if value.is_a? String + cmd << "\"#{key}\":\"#{value}\"" + else + cmd << "\"#{key}\":#{value}" + end + first_param = false + end + + cmd << "}'" + if node['rabbitmq']['version'] >= '3.2.0' + cmd << " --priority #{new_resource.priority}" if new_resource.priority + else + cmd << " #{new_resource.priority}" if new_resource.priority + end + + execute "set_policy #{new_resource.policy}" do + command cmd + end + + new_resource.updated_by_last_action(true) + Chef::Log.info "Done setting RabbitMQ policy '#{new_resource.policy}'." + end +end + +action :clear do + if policy_exists?(new_resource.vhost, new_resource.policy) + execute "clear_policy #{new_resource.policy}" do + command "rabbitmqctl clear_policy #{new_resource.policy}" + end + + new_resource.updated_by_last_action(true) + Chef::Log.info "Done clearing RabbitMQ policy '#{new_resource.policy}'." + end +end + +action :list do + execute 'list_policies' do + command 'rabbitmqctl list_policies' + end + + new_resource.updated_by_last_action(true) +end diff --git a/rabbitmq/providers/user.rb b/rabbitmq/providers/user.rb new file mode 100644 index 000000000..3049a9c76 --- /dev/null +++ b/rabbitmq/providers/user.rb @@ -0,0 +1,165 @@ +# +# Cookbook Name:: rabbitmq +# Provider:: user +# +# Copyright 2011-2013, Opscode, Inc. +# +# 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. +# + +use_inline_resources + +def user_exists?(name) + cmd = "rabbitmqctl -q list_users |grep '^#{name}\\b'" + cmd = Mixlib::ShellOut.new(cmd) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.run_command + Chef::Log.debug "rabbitmq_user_exists?: #{cmd}" + Chef::Log.debug "rabbitmq_user_exists?: #{cmd.stdout}" + begin + cmd.error! + true + rescue + false + end +end + +def user_has_tag?(name, tag) + tag = '"\[\]"' if tag.nil? + cmd = "rabbitmqctl -q list_users | grep \"^#{name}\\b\" | grep #{tag}" + cmd = Mixlib::ShellOut.new(cmd) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.run_command + Chef::Log.debug "rabbitmq_user_has_tag?: #{cmd}" + Chef::Log.debug "rabbitmq_user_has_tag?: #{cmd.stdout}" + begin + cmd.error! + true + rescue RuntimeError + false + end +end + +# does the user have the rights listed on the vhost? +# empty perm_list means we're checking for any permissions +def user_has_permissions?(name, vhost, perm_list = nil) + vhost = '/' if vhost.nil? + cmd = "rabbitmqctl -q list_user_permissions #{name} | grep \"^#{vhost}\\b\"" + cmd = Mixlib::ShellOut.new(cmd) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.run_command + Chef::Log.debug "rabbitmq_user_has_permissions?: #{cmd}" + Chef::Log.debug "rabbitmq_user_has_permissions?: #{cmd.stdout}" + Chef::Log.debug "rabbitmq_user_has_permissions?: #{cmd.exitstatus}" + if perm_list.nil? && cmd.stdout.empty? # looking for empty and found nothing + Chef::Log.debug 'rabbitmq_user_has_permissions?: no permissions found' + return false + end + if perm_list == cmd.stdout.split.drop(1) # existing match search + Chef::Log.debug 'rabbitmq_user_has_permissions?: matching permissions already found' + return true + end + Chef::Log.debug 'rabbitmq_user_has_permissions?: permissions found but do not match' + false +end + +action :add do + unless user_exists?(new_resource.user) + Chef::Application.fatal!('rabbitmq_user with action :add requires a non-nil/empty password.') if new_resource.password.nil? || new_resource.password.empty? + + # To escape single quotes in a shell, you have to close the surrounding single quotes, add + # in an escaped single quote, and then re-open the original single quotes. + # Since this string is interpolated once by ruby, and then a second time by the shell, we need + # to escape the escape character ('\') twice. This is why the following is such a mess + # of leaning toothpicks: + new_password = new_resource.password.gsub("'", "'\\\\''") + cmd = "rabbitmqctl add_user #{new_resource.user} '#{new_password}'" + execute "rabbitmqctl add_user #{new_resource.user}" do + #sensitive true + command cmd + Chef::Log.info "Adding RabbitMQ user '#{new_resource.user}'." + end + end +end + +action :delete do + if user_exists?(new_resource.user) + cmd = "rabbitmqctl delete_user #{new_resource.user}" + execute cmd do + Chef::Log.debug "rabbitmq_user_delete: #{cmd}" + Chef::Log.info "Deleting RabbitMQ user '#{new_resource.user}'." + end + end +end + +action :set_permissions do + Chef::Application.fatal!("rabbitmq_user action :set_permissions fails with non-existant '#{new_resource.user}' user.") unless user_exists?(new_resource.user) + + perm_list = new_resource.permissions.split + unless user_has_permissions?(new_resource.user, new_resource.vhost, perm_list) + vhostopt = "-p #{new_resource.vhost}" unless new_resource.vhost.nil? + cmd = "rabbitmqctl set_permissions #{vhostopt} #{new_resource.user} \"#{perm_list.join("\" \"")}\"" + execute cmd do + Chef::Log.debug "rabbitmq_user_set_permissions: #{cmd}" + Chef::Log.info "Setting RabbitMQ user permissions for '#{new_resource.user}' on vhost #{new_resource.vhost}." + end + end +end + +action :clear_permissions do + Chef::Application.fatal!("rabbitmq_user action :clear_permissions fails with non-existant '#{new_resource.user}' user.") unless user_exists?(new_resource.user) + + if user_has_permissions?(new_resource.user, new_resource.vhost) + vhostopt = "-p #{new_resource.vhost}" unless new_resource.vhost.nil? + cmd = "rabbitmqctl clear_permissions #{vhostopt} #{new_resource.user}" + execute cmd do + Chef::Log.debug "rabbitmq_user_clear_permissions: #{cmd}" + Chef::Log.info "Clearing RabbitMQ user permissions for '#{new_resource.user}' from vhost #{new_resource.vhost}." + end + end +end + +action :set_tags do + Chef::Application.fatal!("rabbitmq_user action :set_tags fails with non-existant '#{new_resource.user}' user.") unless user_exists?(new_resource.user) + + unless user_has_tag?(new_resource.user, new_resource.tag) + cmd = "rabbitmqctl set_user_tags #{new_resource.user} #{new_resource.tag}" + execute cmd do + Chef::Log.debug "rabbitmq_user_set_tags: #{cmd}" + Chef::Log.info "Setting RabbitMQ user '#{new_resource.user}' tags '#{new_resource.tag}'" + end + end +end + +action :clear_tags do + Chef::Application.fatal!("rabbitmq_user action :clear_tags fails with non-existant '#{new_resource.user}' user.") unless user_exists?(new_resource.user) + + unless user_has_tag?(new_resource.user, '"\[\]"') + cmd = "rabbitmqctl set_user_tags #{new_resource.user}" + execute cmd do + Chef::Log.debug "rabbitmq_user_clear_tags: #{cmd}" + Chef::Log.info "Clearing RabbitMQ user '#{new_resource.user}' tags." + end + end +end + +action :change_password do + if user_exists?(new_resource.user) + cmd = "rabbitmqctl change_password #{new_resource.user} #{new_resource.password}" + execute cmd do + #sensitive true + Chef::Log.debug "rabbitmq_user_change_password: #{cmd}" + Chef::Log.info "Editing RabbitMQ user '#{new_resource.user}'." + end + end +end diff --git a/rabbitmq/providers/vhost.rb b/rabbitmq/providers/vhost.rb new file mode 100644 index 000000000..5b8fd7c8d --- /dev/null +++ b/rabbitmq/providers/vhost.rb @@ -0,0 +1,55 @@ +# +# Cookbook Name:: rabbitmq +# Provider:: vhost +# +# Copyright 2011-2013, Opscode, Inc. +# +# 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. +# + +def vhost_exists?(name) + cmd = "rabbitmqctl -q list_vhosts | grep ^#{name}$" + cmd = Mixlib::ShellOut.new(cmd) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') + cmd.run_command + Chef::Log.debug "rabbitmq_vhost_exists?: #{cmd}" + Chef::Log.debug "rabbitmq_vhost_exists?: #{cmd.stdout}" + begin + cmd.error! + true + rescue + false + end +end + +action :add do + unless vhost_exists?(new_resource.vhost) + cmd = "rabbitmqctl add_vhost #{new_resource.vhost}" + execute cmd do + Chef::Log.debug "rabbitmq_vhost_add: #{cmd}" + Chef::Log.info "Adding RabbitMQ vhost '#{new_resource.vhost}'." + new_resource.updated_by_last_action(true) + end + end +end + +action :delete do + if vhost_exists?(new_resource.vhost) + cmd = "rabbitmqctl delete_vhost #{new_resource.vhost}" + execute cmd do + Chef::Log.debug "rabbitmq_vhost_delete: #{cmd}" + Chef::Log.info "Deleting RabbitMQ vhost '#{new_resource.vhost}'." + new_resource.updated_by_last_action(true) + end + end +end diff --git a/rabbitmq/recipes/default.rb b/rabbitmq/recipes/default.rb new file mode 100644 index 000000000..9d5620fcb --- /dev/null +++ b/rabbitmq/recipes/default.rb @@ -0,0 +1,194 @@ +# +# Cookbook Name:: rabbitmq +# Recipe:: default +# +# Copyright 2009, Benjamin Black +# Copyright 2009-2013, Opscode, Inc. +# Copyright 2012, Kevin Nuckolls +# +# 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. +# + +# +class Chef::Resource + include Opscode::RabbitMQ +end + +include_recipe 'erlang' + +## Install the package +case node['platform_family'] +when 'debian' + # logrotate is a package dependency of rabbitmq-server + package 'logrotate' + + if node['rabbitmq']['use_distro_version'] + package 'rabbitmq-server' + else + # we need to download the package + deb_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" + remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" do + source deb_package + action :create_if_missing + end + dpkg_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb" + end + + # Configure job control + if node['rabbitmq']['job_control'] == 'upstart' + # We start with stock init.d, remove it if we're not using init.d, otherwise leave it alone + service node['rabbitmq']['service_name'] do + action [:stop] + only_if { File.exist?('/etc/init.d/rabbitmq-server') } + end + + execute 'remove rabbitmq init.d command' do + command 'update-rc.d -f rabbitmq-server remove' + end + + file '/etc/init.d/rabbitmq-server' do + action :delete + end + + template "/etc/init/#{node['rabbitmq']['service_name']}.conf" do + source 'rabbitmq.upstart.conf.erb' + owner 'root' + group 'root' + mode 0644 + variables(:max_file_descriptors => node['rabbitmq']['max_file_descriptors']) + end + + service node['rabbitmq']['service_name'] do + provider Chef::Provider::Service::Upstart + action [:enable, :start] + # restart_command "stop #{node['rabbitmq']['service_name']} && start #{node['rabbitmq']['service_name']}" + end + end + + if node['rabbitmq']['job_control'] == 'initd' + service node['rabbitmq']['service_name'] do + supports :status => true, :restart => true + action [:enable, :start] + end + end + +when 'rhel', 'fedora' + # This is needed since Erlang Solutions' packages provide "esl-erlang"; this package just requires "esl-erlang" and provides "erlang". + if node['erlang']['install_method'] == 'esl' + remote_file "#{Chef::Config[:file_cache_path]}/esl-erlang-compat.rpm" do + source 'https://github.com/jasonmcintosh/esl-erlang-compat/blob/master/rpmbuild/RPMS/noarch/esl-erlang-compat-R14B-1.el6.noarch.rpm?raw=true' + end + rpm_package "#{Chef::Config[:file_cache_path]}/esl-erlang-compat.rpm" + end + + if node['rabbitmq']['use_distro_version'] + package 'rabbitmq-server' + else + # We need to download the rpm + rpm_package = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" + + remote_file "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" do + source rpm_package + action :create_if_missing + end + rpm_package "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" + end + + service node['rabbitmq']['service_name'] do + action [:enable, :start] + end + +when 'suse' + # rabbitmq-server-plugins needs to be first so they both get installed + # from the right repository. Otherwise, zypper will stop and ask for a + # vendor change. + package 'rabbitmq-server-plugins' + package 'rabbitmq-server' + + service node['rabbitmq']['service_name'] do + action [:enable, :start] + end +when 'smartos' + package 'rabbitmq' + + service 'epmd' do + action :start + end + + service node['rabbitmq']['service_name'] do + action [:enable, :start] + end +end + +if node['rabbitmq']['logdir'] + directory node['rabbitmq']['logdir'] do + owner 'rabbitmq' + group 'rabbitmq' + mode '775' + recursive true + end +end + +directory node['rabbitmq']['mnesiadir'] do + owner 'rabbitmq' + group 'rabbitmq' + mode '775' + recursive true +end + +template "#{node['rabbitmq']['config_root']}/rabbitmq-env.conf" do + source 'rabbitmq-env.conf.erb' + owner 'root' + group 'root' + mode 00644 + notifies :restart, "service[#{node['rabbitmq']['service_name']}]", :immediately +end + +template "#{node['rabbitmq']['config_root']}/rabbitmq.config" do + #sensitive true + source 'rabbitmq.config.erb' + owner 'root' + group 'root' + mode 00644 + variables( + :kernel => format_kernel_parameters + ) + notifies :restart, "service[#{node['rabbitmq']['service_name']}]", :immediately +end + +if File.exist?(node['rabbitmq']['erlang_cookie_path']) + existing_erlang_key = File.read(node['rabbitmq']['erlang_cookie_path']).strip +else + existing_erlang_key = '' +end + +if node['rabbitmq']['cluster'] && (node['rabbitmq']['erlang_cookie'] != existing_erlang_key) + log "stop #{node['rabbitmq']['serice_name']} to change erlang cookie" do + notifies :stop, "service[#{node['rabbitmq']['service_name']}]", :immediately + end + + template node['rabbitmq']['erlang_cookie_path'] do + source 'doterlang.cookie.erb' + owner 'rabbitmq' + group 'rabbitmq' + mode 00400 + notifies :start, "service[#{node['rabbitmq']['service_name']}]", :immediately + notifies :run, 'execute[reset-node]', :immediately + end + + # Need to reset for clustering # + execute 'reset-node' do + command 'rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl start_app' + action :nothing + end +end diff --git a/rabbitmq/recipes/mgmt_console.rb b/rabbitmq/recipes/mgmt_console.rb new file mode 100644 index 000000000..ace1ba684 --- /dev/null +++ b/rabbitmq/recipes/mgmt_console.rb @@ -0,0 +1,31 @@ +# +# Cookbook Name:: rabbitmq +# Recipe:: mgmt_console +# +# Copyright 2012, Tacit Knowledge, Inc. +# +# 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. +# + +include_recipe 'rabbitmq::default' + +plugins = %w( rabbitmq_management rabbitmq_management_visualiser ) + +service_name = node['rabbitmq']['service_name'] + +plugins.each do |plugin| + rabbitmq_plugin plugin do + action :enable + notifies :restart, "service[#{service_name}]", :immediately + end +end diff --git a/rabbitmq/recipes/plugin_management.rb b/rabbitmq/recipes/plugin_management.rb new file mode 100644 index 000000000..f6fd03990 --- /dev/null +++ b/rabbitmq/recipes/plugin_management.rb @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# +# Cookbook Name:: rabbitmq +# Recipe:: plugin_management +# +# Copyright 2013, Grégoire Seux +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +include_recipe 'rabbitmq::default' + +node['rabbitmq']['enabled_plugins'].each do |plugin| + rabbitmq_plugin plugin do + action :enable + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end + +node['rabbitmq']['disabled_plugins'].each do |plugin| + rabbitmq_plugin plugin do + action :disable + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end diff --git a/rabbitmq/recipes/policy_management.rb b/rabbitmq/recipes/policy_management.rb new file mode 100644 index 000000000..a9c15aa29 --- /dev/null +++ b/rabbitmq/recipes/policy_management.rb @@ -0,0 +1,40 @@ +# +# Cookbook Name:: rabbitmq +# Recipe:: policy_management +# +# Author: Robert Choi +# Copyright 2013 by Robert Choi +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +include_recipe 'rabbitmq::default' + +node['rabbitmq']['policies'].each do |name, policy| + rabbitmq_policy name do + pattern policy['pattern'] + params policy['params'] + priority policy['priority'] + vhost policy['vhost'] + action :set + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end + +node['rabbitmq']['disabled_policies'].each do |policy| + rabbitmq_policy policy do + action :clear + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end diff --git a/rabbitmq/recipes/user_management.rb b/rabbitmq/recipes/user_management.rb new file mode 100644 index 000000000..27167c096 --- /dev/null +++ b/rabbitmq/recipes/user_management.rb @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# +# Cookbook Name:: rabbitmq +# Recipe:: user_management +# +# Copyright 2013, Grégoire Seux +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +include_recipe 'rabbitmq::default' +include_recipe 'rabbitmq::virtualhost_management' + +node['rabbitmq']['enabled_users'].each do |user| + rabbitmq_user user['name'] do + password user['password'] + action :add + end + rabbitmq_user user['name'] do + tag user['tag'] + action :set_tags + end + user['rights'].each do |r| + rabbitmq_user user['name'] do + vhost r['vhost'] + permissions "#{r['conf']} #{r['write']} #{r['read']}" + action :set_permissions + end + end +end + +node['rabbitmq']['disabled_users'].each do |user| + rabbitmq_user user do + action :delete + end +end diff --git a/rabbitmq/recipes/virtualhost_management.rb b/rabbitmq/recipes/virtualhost_management.rb new file mode 100644 index 000000000..c427e79bf --- /dev/null +++ b/rabbitmq/recipes/virtualhost_management.rb @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# +# Cookbook Name:: rabbitmq +# Recipe:: virtualhost_management +# +# Copyright 2013, Grégoire Seux +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +include_recipe 'rabbitmq::default' + +node['rabbitmq']['virtualhosts'].each do |virtualhost| + rabbitmq_vhost virtualhost do + action :add + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end + +node['rabbitmq']['disabled_virtualhosts'].each do |virtualhost| + rabbitmq_vhost virtualhost do + action :delete + notifies :restart, "service[#{node['rabbitmq']['service_name']}]" + end +end diff --git a/rabbitmq/resources/plugin.rb b/rabbitmq/resources/plugin.rb new file mode 100644 index 000000000..4980c7a7e --- /dev/null +++ b/rabbitmq/resources/plugin.rb @@ -0,0 +1,23 @@ +# +# Cookbook Name:: rabbitmq +# Resource:: plugin +# +# Copyright 2011, Opscode, Inc. +# +# 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. +# + +actions :enable, :disable +default_action :enable + +attribute :plugin, :kind_of => String, :name_attribute => true diff --git a/rabbitmq/resources/policy.rb b/rabbitmq/resources/policy.rb new file mode 100644 index 000000000..5f63a97ce --- /dev/null +++ b/rabbitmq/resources/policy.rb @@ -0,0 +1,28 @@ +# +# Cookbook Name:: rabbitmq +# Resource:: policy +# +# Author: Robert Choi +# Copyright 2013 by Robert Choi +# +# 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. +# + +actions :set, :clear, :list +default_action :set + +attribute :policy, :kind_of => String, :name_attribute => true +attribute :pattern, :kind_of => String +attribute :params, :kind_of => Hash +attribute :priority, :kind_of => Integer +attribute :vhost, :kind_of => String diff --git a/rabbitmq/resources/user.rb b/rabbitmq/resources/user.rb new file mode 100644 index 000000000..c96f6871a --- /dev/null +++ b/rabbitmq/resources/user.rb @@ -0,0 +1,31 @@ +# +# Cookbook Name:: rabbitmq +# Resource:: user +# +# Copyright 2011-2013, Opscode, Inc. +# +# 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. +# + +actions :add, :delete, :set_permissions, :clear_permissions, :set_tags, :clear_tags, :change_password + +attribute :user, :kind_of => String, :name_attribute => true +attribute :password, :kind_of => String +attribute :vhost, :kind_of => String +attribute :permissions, :kind_of => String +attribute :tag, :kind_of => String + +def initialize(*args) + super + @action = :add +end diff --git a/rabbitmq/resources/vhost.rb b/rabbitmq/resources/vhost.rb new file mode 100644 index 000000000..312b04c1f --- /dev/null +++ b/rabbitmq/resources/vhost.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: rabbitmq +# Resource:: vhost +# +# Copyright 2011, Opscode, Inc. +# +# 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. +# + +actions :add, :delete + +attribute :vhost, :kind_of => String, :name_attribute => true + +def initialize(*args) + super + @action = :add +end diff --git a/rabbitmq/spec/spec_helper.rb b/rabbitmq/spec/spec_helper.rb new file mode 100644 index 000000000..4e0000484 --- /dev/null +++ b/rabbitmq/spec/spec_helper.rb @@ -0,0 +1,4 @@ +require 'chefspec' +require 'chefspec/berkshelf' + +at_exit { ChefSpec::Coverage.report! } diff --git a/rabbitmq/templates/default/doterlang.cookie.erb b/rabbitmq/templates/default/doterlang.cookie.erb new file mode 100644 index 000000000..a142e47a3 --- /dev/null +++ b/rabbitmq/templates/default/doterlang.cookie.erb @@ -0,0 +1 @@ +<%= node['rabbitmq']['erlang_cookie'] %> diff --git a/rabbitmq/templates/default/rabbitmq-env.conf.erb b/rabbitmq/templates/default/rabbitmq-env.conf.erb new file mode 100644 index 000000000..a92eba040 --- /dev/null +++ b/rabbitmq/templates/default/rabbitmq-env.conf.erb @@ -0,0 +1,22 @@ +### +# Generated by Chef +### + +<% if node['rabbitmq']['local_erl_networking'] -%> +NODENAME=rabbit@localhost +NODE_IP_ADDRESS=127.0.0.1 +export ERL_EPMD_ADDRESS=127.0.0.1 +<% elsif node['rabbitmq']['erl_networking_bind_address'] -%> +NODENAME=<%= node['rabbitmq']['nodename'] %> +NODE_IP_ADDRESS=<%= node['rabbitmq']['erl_networking_bind_address'] %> +export ERL_EPMD_ADDRESS=<%= node['rabbitmq']['erl_networking_bind_address'] %> +<% else -%> +<% if node['rabbitmq']['address'] -%>NODE_IP_ADDRESS=<%= node['rabbitmq']['address'] %><% end %> +<% if node['rabbitmq']['nodename'] -%>NODENAME=<%= node['rabbitmq']['nodename'] %><% end %> +<% end -%> +<% if node['rabbitmq']['port'] -%>NODE_PORT=<%= node['rabbitmq']['port'] %><% end %> +<% if node['rabbitmq']['config'] -%>CONFIG_FILE=<%= node['rabbitmq']['config'] %><% end %> +<% if node['rabbitmq']['logdir'] -%>LOG_BASE=<%= node['rabbitmq']['logdir'] %><% end %> +<% if node['rabbitmq']['mnesiadir'] -%>MNESIA_BASE=<%= node['rabbitmq']['mnesiadir'] %><% end %> + +<% if node['rabbitmq']['open_file_limit'] -%>ulimit -n <%= node['rabbitmq']['open_file_limit'] %><% end %> diff --git a/rabbitmq/templates/default/rabbitmq.config.erb b/rabbitmq/templates/default/rabbitmq.config.erb new file mode 100644 index 000000000..d50b8f188 --- /dev/null +++ b/rabbitmq/templates/default/rabbitmq.config.erb @@ -0,0 +1,51 @@ +%%% +%% Generated by Chef +%%% + +[ + {kernel, [ +<%= @kernel %> + ]}, +<% if node['rabbitmq']['web_console_ssl'] -%> + {rabbitmq_management, [ + {listener, [{port, <%= node['rabbitmq']['web_console_ssl_port'] %>}, + {ssl, true}, + {ssl_opts, [{cacertfile,"<%= node['rabbitmq']['ssl_cacert'] %>"}, + {certfile,"<%= node['rabbitmq']['ssl_cert'] %>"}, + {keyfile,"<%= node['rabbitmq']['ssl_key'] %>"}]} + ]} + ]}, +<% end %> + {rabbit, [ +<% if node['rabbitmq']['cluster'] && node['rabbitmq']['cluster_disk_nodes'] -%> + {cluster_nodes, {[<%= node['rabbitmq']['cluster_disk_nodes'].map{|n| "\'#{n}\'"}.sort.join(',') %>], disc}}, + {cluster_partition_handling,<%= node['rabbitmq']['cluster_partition_handling'] %>}, +<% end %> +<% if node['rabbitmq']['ssl'] -%> + {ssl_listeners, [<%= node['rabbitmq']['ssl_port'] %>]}, + {ssl_options, [{cacertfile,"<%= node['rabbitmq']['ssl_cacert'] %>"}, + {certfile,"<%= node['rabbitmq']['ssl_cert'] %>"}, + {keyfile,"<%= node['rabbitmq']['ssl_key'] %>"}, + {verify,<%= node['rabbitmq']['ssl_verify'] %>}, + {fail_if_no_peer_cert,<%= node['rabbitmq']['ssl_fail_if_no_peer_cert'] %>}]}, +<% end %> +<% if node['rabbitmq']['tcp_listen'] -%> + {tcp_listen_options, [binary, {packet,<%= node['rabbitmq']['tcp_listen_packet'] %>}, + {reuseaddr,<%= node['rabbitmq']['tcp_listen_reuseaddr'] %>}, + {backlog,<%= node['rabbitmq']['tcp_listen_backlog'] %>}, + {nodelay,<%= node['rabbitmq']['tcp_listen_nodelay'] %>}, + {exit_on_close,<%= node['rabbitmq']['tcp_listen_exit_on_close'] %>}, + {keepalive,<%= node['rabbitmq']['tcp_listen_keepalive'] %>}]}, +<% else -%> + {tcp_listeners, []}, +<% end %> +<% if node['rabbitmq']['disk_free_limit_relative'] -%> + {disk_free_limit, {mem_relative, <%= node['rabbitmq']['disk_free_limit_relative'] %>}}, +<% end %> +<% if node['rabbitmq']['vm_memory_high_watermark'] -%> + {vm_memory_high_watermark, <%= node['rabbitmq']['vm_memory_high_watermark'] %>}, +<% end %> + {default_user, <<"<%= node['rabbitmq']['default_user'] %>">>}, + {default_pass, <<"<%= node['rabbitmq']['default_pass'] %>">>} + ]} +]. diff --git a/rabbitmq/templates/default/rabbitmq.upstart.conf.erb b/rabbitmq/templates/default/rabbitmq.upstart.conf.erb new file mode 100644 index 000000000..9389ee685 --- /dev/null +++ b/rabbitmq/templates/default/rabbitmq.upstart.conf.erb @@ -0,0 +1,25 @@ +description "Start rabbitmq on startup" +start on started networking +limit nofile <%= @max_file_descriptors %> <%= @max_file_descriptors %> + +respawn +respawn limit 5 60 + +env HOME="" +env RABBITMQ_PID_FILE="/var/run/rabbitmq/pid" + +pre-start script + PID_DIR=`dirname ${RABBITMQ_PID_FILE}` + + if [ ! -d ${PID_DIR} ]; + then + mkdir -p ${PID_DIR} + chown -R rabbitmq:rabbitmq ${PID_DIR} + chmod 755 ${PID_DIR} + fi +end script + +exec /usr/sbin/rabbitmq-server > /var/log/rabbitmq/startup_log \ + 2> /var/log/rabbitmq/startup_err + +post-start exec /usr/sbin/rabbitmqctl wait $RABBITMQ_PID_FILE >/dev/null 2>&1 diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/README.md b/rabbitmq/test/cookbooks/rabbitmq_test/README.md new file mode 100644 index 000000000..d348825b5 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/README.md @@ -0,0 +1 @@ +This cookbook is used with test-kitchen to test the parent, rabbitmq cookbook. diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cluster_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cluster_test.rb new file mode 100644 index 000000000..da71a59e3 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cluster_test.rb @@ -0,0 +1,29 @@ +# +# Copyright 2012, Opscode, Inc. +# +# 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. +# + +describe 'rabbitmq_test::cluster' do + + it 'writes the erlang cookie file' do + file('/var/lib/rabbitmq/.erlang.cookie').must_exist + end + + it 'writes cluster configuration to the config file' do + file('/etc/rabbitmq/rabbitmq.conf').must_match( + /^ {cluster_nodes, [.*]},$/ + ) + end + +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1684_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1684_test.rb new file mode 100644 index 000000000..3497580c7 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1684_test.rb @@ -0,0 +1,37 @@ +# +# Copyright 2012, Opscode, Inc. +# +# 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. +# + +describe 'rabbitmq_test::cook-1684' do + include MiniTest::Chef::Assertions + include MiniTest::Chef::Context + include MiniTest::Chef::Resources + + it 'installs rabbitmq from deb file when apt isnt used' do + skip 'Only applicable on Debian family' unless node['platform_family'] == 'debian' + + file("#{Chef::Config[:file_cache_path]}/rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb").must_exist && + package('rabbitmq-server').must_be_installed + end + + it 'installs rabbitmq from yum when used' do + skip 'Only applicable on RHEL/Fedora family' unless node['platform_family'] == 'rhel' || node['platform_family'] == 'fedora' + + rpm_path = "#{Chef::Config[:file_cache_path]}/rabbitmq-server-#{node['rabbitmq']['version']}-1.noarch.rpm" + + file(rpm_path).wont_exist && package('rabbitmq-server').must_be_installed + end + +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1724_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1724_test.rb new file mode 100644 index 000000000..73ff9530c --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-1724_test.rb @@ -0,0 +1,29 @@ +# +# Copyright 2012, Opscode, Inc. +# +# 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. +# + +describe 'rabbitmq_test::cook-1724' do + include MiniTest::Chef::Assertions + include MiniTest::Chef::Context + include MiniTest::Chef::Resources + + it 'doesnt use the rabbitmq apt repository' do + skip 'Only applicable on Debian family' unless node['platform_family'] == 'debian' + + file('/etc/apt/sources.list.d/rabbitmq-source.list').wont_exist && + package('rabbitmq-server').must_be_installed + end + +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-2151-3489_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-2151-3489_test.rb new file mode 100644 index 000000000..7588127e5 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/cook-2151-3489_test.rb @@ -0,0 +1,37 @@ +# +# Copyright 2012-2013, Opscode, Inc. +# +# 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. +# + +require File.expand_path('../support/helpers', __FILE__) + +describe 'rabbitmq_test::cook-2151' do + include Helpers::RabbitMQ + + it 'includes the disk_free_limit configuration setting' do + file("#{node['rabbitmq']['config_root']}/rabbitmq.config") + .must_match(/\{disk_free_limit, \{mem_relative, #{node['rabbitmq']['disk_free_limit_relative']}/) + end + + it 'includes the vm_memory_high_watermark configuration setting' do + file("#{node['rabbitmq']['config_root']}/rabbitmq.config") + .must_match(/\{vm_memory_high_watermark, #{node['rabbitmq']['vm_memory_high_watermark']}/) + end + + it 'includes the open_file_limit configuration setting' do + file("#{node['rabbitmq']['config_root']}/rabbitmq-env.conf") + .must_match(/(ulimit -n #{node['rabbitmq']['open_file_limit']})/) + end + +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/default_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/default_test.rb new file mode 100644 index 000000000..7d43c156d --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/default_test.rb @@ -0,0 +1,60 @@ +# +# Copyright 2012-2013, Opscode, Inc. +# +# 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. +# + +require File.expand_path('../support/helpers', __FILE__) + +describe 'rabbitmq_test::default' do + include Helpers::RabbitMQ + + # packages + it 'installs the rabbitmq-server package' do + if node['rabbitmq']['use_distro_version'] + package('rabbitmq-server').must_be_installed + else + package('rabbitmq-server').must_be_installed.with(:version, '3.1.5-1') + end + end + + # directories + it 'creates the mnesia directory' do + directory(node['rabbitmq']['mnesiadir']).must_have(:mode, '775').with(:owner, 'rabbitmq').and(:group, 'rabbitmq') + end + + # file + it 'has the correct config files' do + file("#{node['rabbitmq']['config_root']}/rabbitmq-env.conf").must_exist.with(:owner, 'root').and(:group, 'root') + file("#{node['rabbitmq']['config_root']}/rabbitmq.config").must_exist.with(:owner, 'root').and(:group, 'root') + end + + # service + it 'enables & starts the rabbitmq-server service' do + service(node['rabbitmq']['service_name']).must_be_enabled unless node['rabbitmq']['job_control'] == 'upstart' + service(node['rabbitmq']['service_name']).must_be_running unless node['rabbitmq']['use_distro_version'] + end + + # accepts connections + it 'accepts AMQP connections' do + unless node['rabbitmq']['use_distro_version'] + require 'bunny' + b = Bunny.new(:host => 'localhost', + :port => 5672, + :user => node['rabbitmq']['default_user'], + :pass => node['rabbitmq']['default_pass']) + b.start + b.stop + end + end +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/lwrps_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/lwrps_test.rb new file mode 100644 index 000000000..474c02be5 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/lwrps_test.rb @@ -0,0 +1,61 @@ +# +# Copyright 2013, Opscode, Inc. +# +# 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. +# + +require File.expand_path('../support/helpers', __FILE__) + +describe 'rabbitmq_test::lwrps' do + include Helpers::RabbitMQ + + # plugins + it 'enabled the rabbitmq_stomp plugin' do + assert(plugin_enabled?('rabbitmq_stomp')) + end + + it 'disabled the nonexistant_plugin and rabbitmq_shovel plugin' do + assert(!plugin_enabled?('rabbitmq_shovel')) + assert(!plugin_enabled?('nonexistant_plugin')) + end + + # users + it 'enabled the kitchen1 and kitchen3 users' do + assert(user_enabled?('kitchen1')) + assert(user_enabled?('kitchen3')) + end + + it 'disabled the nonexistant_user and kitchen2 users' do + assert(!user_enabled?('kitchen2')) + assert(!user_enabled?('nonexistant_user')) + end + + # policies + it 'enabled the example policies from the default attributes' do + assert(policy_enabled?('ha-all')) + assert(policy_enabled?('ha-two')) + end + + it 'disabled the nonexistant_policy' do + assert(!policy_enabled?('nonexistant_policy')) + end + + # vhosts + it 'enabled the kitchen vhost' do + assert(vhost_enabled?('kitchen')) + end + + it 'disabled the nonexistant_vhost' do + assert(!vhost_enabled?('nonexistant_vhost')) + end +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/mgmt_console_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/mgmt_console_test.rb new file mode 100644 index 000000000..8aab40dda --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/mgmt_console_test.rb @@ -0,0 +1,30 @@ +# +# Copyright 2012-2013, Opscode, Inc. +# +# 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. +# + +require File.expand_path('../support/helpers', __FILE__) + +describe 'rabbitmq_test::mgmt_console' do + include Helpers::RabbitMQ + + it 'enables the rabbitmq_management plugin' do + assert(plugin_enabled?('rabbitmq_management')) + end + + it 'enables the rabbitmq_management_visualiser plugin' do + assert(plugin_enabled?('rabbitmq_management_visualiser')) + end + +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/ssl_test.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/ssl_test.rb new file mode 100644 index 000000000..f576a8bce --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/ssl_test.rb @@ -0,0 +1,18 @@ +# +# Copyright 2012, Opscode, Inc. +# +# 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. +# + +describe 'rabbitmq_test::ssl' do +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/support/helpers.rb b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/support/helpers.rb new file mode 100644 index 000000000..964cc0262 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/files/default/tests/minitest/support/helpers.rb @@ -0,0 +1,45 @@ +# +# Copyright 2012-2013, Opscode, Inc. +# +# 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. +# + +module Helpers + # rabbitmq + module RabbitMQ + require 'mixlib/shellout' + include MiniTest::Chef::Assertions + include MiniTest::Chef::Context + include MiniTest::Chef::Resources + + def plugin_enabled?(plugin) + plugins = Mixlib::ShellOut.new("rabbitmq-plugins list -e '#{plugin}'").run_command + plugins.stdout =~ /(\[[Ee]\]\s#{plugin})/ + end + + def policy_enabled?(policy) + policies = Mixlib::ShellOut.new('rabbitmqctl -q list_policies').run_command + policies.stdout =~ /\t#{policy}\t/ + end + + def user_enabled?(user) + users = Mixlib::ShellOut.new('rabbitmqctl -q list_users').run_command + users.stdout =~ /(#{user}\s)/ + end + + def vhost_enabled?(vhost) + vhosts = Mixlib::ShellOut.new('rabbitmqctl -q list_vhosts').run_command + vhosts.stdout =~ /(\n#{vhost}\n)/ + end + end +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/metadata.rb b/rabbitmq/test/cookbooks/rabbitmq_test/metadata.rb new file mode 100644 index 000000000..14609eaf5 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/metadata.rb @@ -0,0 +1,8 @@ +name 'rabbitmq_test' +maintainer 'Opscode, Inc.' +maintainer_email 'cookbooks@opscode.com' +license 'Apache 2.0' +description 'This cookbook is used with test-kitchen to test the parent, rabbitmq cookbook.' +version '1.0.0' + +depends 'rabbitmq' diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cluster.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cluster.rb new file mode 100644 index 000000000..3ee4f619f --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cluster.rb @@ -0,0 +1,21 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: cluster +# +# Copyright 2012, Opscode, Inc. +# +# 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. +# + +node.set['rabbitmq']['cluster'] = true +include_recipe 'rabbitmq::default' diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cook-2151-3489.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cook-2151-3489.rb new file mode 100644 index 000000000..acbf11297 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/cook-2151-3489.rb @@ -0,0 +1,14 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: cook-2151-3489 +# +# This recipe exists to ensure that minitest tests are run. + +include_recipe 'rabbitmq::default' + +# HACK: Give rabbit time to spin up before the tests, it seems +# to be responding that it has started before it really has +execute 'sleep 10' do + action :nothing + subscribes :run, "service[#{node['rabbitmq']['service_name']}]", :delayed +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/default.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/default.rb new file mode 100644 index 000000000..59bccd543 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/default.rb @@ -0,0 +1,29 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: default +# +# Copyright 2012-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +chef_gem 'bunny' + +include_recipe 'rabbitmq::default' + +# HACK: Give rabbit time to spin up before the tests, it seems +# to be responding that it has started before it really has +execute 'sleep 10' do + action :nothing + subscribes :run, "service[#{node['rabbitmq']['service_name']}]", :delayed +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/lwrps.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/lwrps.rb new file mode 100644 index 000000000..308ab735d --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/lwrps.rb @@ -0,0 +1,52 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: lwrps +# +# Copyright 2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +chef_gem 'bunny' + +include_recipe 'rabbitmq::default' + +# force the rabbitmq restart now, then start testing +execute 'sleep 10' do + notifies :restart, "service[#{node['rabbitmq']['service_name']}]", :immediately +end + +include_recipe 'rabbitmq::plugin_management' +include_recipe 'rabbitmq::virtualhost_management' +include_recipe 'rabbitmq::policy_management' +include_recipe 'rabbitmq::user_management' + +# can't verify it actually goes through without logging in, but at least exercise the code +rabbitmq_user 'kitchen3' do + password 'foobar' + action :change_password +end + +# download the rabbitmqadmin util from management plugin +# this tests an immediate notifies statement +# see https://github.com/kennonkwok/rabbitmq/issues/141 +rabbitmq_plugin 'rabbitmq_management' do + action :enable + notifies :restart, "service[#{node['rabbitmq']['service_name']}]", :immediately # must restart before we can download +end + +remote_file '/usr/local/bin/rabbitmqadmin' do + source 'http://localhost:15672/cli/rabbitmqadmin' + mode '0755' + action :create +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/mgmt_console.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/mgmt_console.rb new file mode 100644 index 000000000..d576124df --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/mgmt_console.rb @@ -0,0 +1,29 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: mgmt_console +# +# Copyright 2012-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +chef_gem 'bunny' + +include_recipe 'rabbitmq::mgmt_console' + +# HACK: Give rabbit time to spin up before the tests, it seems +# to be responding that it has started before it really has +execute 'sleep 10' do + action :nothing + subscribes :run, "service[#{node['rabbitmq']['service_name']}]", :delayed +end diff --git a/rabbitmq/test/cookbooks/rabbitmq_test/recipes/ssl.rb b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/ssl.rb new file mode 100644 index 000000000..468d7ad04 --- /dev/null +++ b/rabbitmq/test/cookbooks/rabbitmq_test/recipes/ssl.rb @@ -0,0 +1,18 @@ +# +# Cookbook Name:: rabbitmq_test +# Recipe:: ssl +# +# Copyright 2012, Opscode, Inc. +# +# 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/rabbitmq/test/integration/cluster/rspec/Gemfile b/rabbitmq/test/integration/cluster/rspec/Gemfile new file mode 100644 index 000000000..f0f4611ce --- /dev/null +++ b/rabbitmq/test/integration/cluster/rspec/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'serverspec', '< 2.0' diff --git a/rabbitmq/test/integration/cluster/rspec/cluster_spec.rb b/rabbitmq/test/integration/cluster/rspec/cluster_spec.rb new file mode 100644 index 000000000..a46d5dda1 --- /dev/null +++ b/rabbitmq/test/integration/cluster/rspec/cluster_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe file('/var/lib/rabbitmq/.erlang.cookie') do + it { should be_file } +end + +describe file('/etc/rabbitmq/rabbitmq.config') do + it { should be_file } + its(:content) { should match /^ {cluster_nodes, {.*}},$/ } +end diff --git a/rabbitmq/test/integration/default/rspec/Gemfile b/rabbitmq/test/integration/default/rspec/Gemfile new file mode 100644 index 000000000..f0f4611ce --- /dev/null +++ b/rabbitmq/test/integration/default/rspec/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'serverspec', '< 2.0' diff --git a/rabbitmq/test/integration/default/rspec/default_spec.rb b/rabbitmq/test/integration/default/rspec/default_spec.rb new file mode 100644 index 000000000..f8ec36959 --- /dev/null +++ b/rabbitmq/test/integration/default/rspec/default_spec.rb @@ -0,0 +1 @@ +require 'spec_helper' diff --git a/rabbitmq/test/integration/helpers/rspec/Gemfile b/rabbitmq/test/integration/helpers/rspec/Gemfile new file mode 100644 index 000000000..f0f4611ce --- /dev/null +++ b/rabbitmq/test/integration/helpers/rspec/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'serverspec', '< 2.0' diff --git a/rabbitmq/test/integration/helpers/rspec/rabbitmq_spec.rb b/rabbitmq/test/integration/helpers/rspec/rabbitmq_spec.rb new file mode 100644 index 000000000..f50556558 --- /dev/null +++ b/rabbitmq/test/integration/helpers/rspec/rabbitmq_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe package('rabbitmq-server') do + it { should be_installed } +end + +describe service('rabbitmq-server') do + it { should be_enabled } + it { should be_running } +end + +describe port(5672) do + it { should be_listening } +end + +describe command('rabbitmqctl status') do + it { should return_exit_status 0 } +end + +describe file('/var/lib/rabbitmq/mnesia') do + it { should be_directory } + it { should be_mode 775 } + it { should be_owned_by 'rabbitmq' } + it { should be_grouped_into 'rabbitmq' } +end + +describe file('/etc/rabbitmq/rabbitmq-env.conf') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } +end + +describe file('/etc/rabbitmq/rabbitmq.config') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } +end diff --git a/rabbitmq/test/integration/helpers/rspec/spec_helper.rb b/rabbitmq/test/integration/helpers/rspec/spec_helper.rb new file mode 100644 index 000000000..2995d5afd --- /dev/null +++ b/rabbitmq/test/integration/helpers/rspec/spec_helper.rb @@ -0,0 +1,13 @@ +require 'serverspec' + +include SpecInfra::Helper::Exec +include SpecInfra::Helper::DetectOS + +RSpec.configure do |c| + if ENV['ASK_SUDO_PASSWORD'] + require 'highline/import' + c.sudo_password = ask('Enter sudo password: ') { |q| q.echo = false } + else + c.sudo_password = ENV['SUDO_PASSWORD'] + end +end diff --git a/rabbitmq/test/integration/lwrps/rspec/Gemfile b/rabbitmq/test/integration/lwrps/rspec/Gemfile new file mode 100644 index 000000000..f0f4611ce --- /dev/null +++ b/rabbitmq/test/integration/lwrps/rspec/Gemfile @@ -0,0 +1,2 @@ +source 'https://rubygems.org' +gem 'serverspec', '< 2.0' diff --git a/rabbitmq/test/integration/lwrps/rspec/lwrps_spec.rb b/rabbitmq/test/integration/lwrps/rspec/lwrps_spec.rb new file mode 100644 index 000000000..24d3f69f2 --- /dev/null +++ b/rabbitmq/test/integration/lwrps/rspec/lwrps_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe file('/usr/local/bin/rabbitmqadmin') do + it { should be_file } + it { should be_executable } +end + +describe command('/usr/local/bin/rabbitmqadmin --version') do + it { should return_exit_status 0 } +end diff --git a/service/README.md b/service/README.md new file mode 100644 index 000000000..106af5987 --- /dev/null +++ b/service/README.md @@ -0,0 +1,3 @@ +# service + +Role recipes for the service stack. diff --git a/service/metadata.rb b/service/metadata.rb new file mode 100644 index 000000000..c3863886e --- /dev/null +++ b/service/metadata.rb @@ -0,0 +1,10 @@ +name 'service' +maintainer 'Till Klampaeckel' +maintainer_email 'till@php.net' +license 'BSD-2-Clause' +description 'Role recipes for the service stack' + +depends 'easybib' +depends 'loggly' +depends 'gearmand' +depends 'rabbitmq' diff --git a/service/recipes/role-gearmand.rb b/service/recipes/role-gearmand.rb new file mode 100644 index 000000000..5dd69c8d0 --- /dev/null +++ b/service/recipes/role-gearmand.rb @@ -0,0 +1,3 @@ +include_recipe 'easybib::setup' +include_recipe 'loggly::setup' +include_recipe 'gearmand' diff --git a/service/recipes/role-rabbitmq.rb b/service/recipes/role-rabbitmq.rb new file mode 100644 index 000000000..f7678c78b --- /dev/null +++ b/service/recipes/role-rabbitmq.rb @@ -0,0 +1,13 @@ +include_recipe 'easybib::setup' + +node.set['rabbitmq']['job_control'] = 'upstart' if platform?('ubuntu') + +include_recipe 'rabbitmq' +include_recipe 'rabbitmq::mgmt_console' + +rabbitmq_user 'guest' do + action :delete +end + +include_recipe 'rabbitmq::virtualhost_management' +include_recipe 'rabbitmq::user_management' diff --git a/vagrant-test/gearman/Vagrantfile b/vagrant-test/gearman/Vagrantfile index f05aab465..b5a214a39 100644 --- a/vagrant-test/gearman/Vagrantfile +++ b/vagrant-test/gearman/Vagrantfile @@ -16,7 +16,7 @@ Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "./../../" - chef.add_recipe "easybib::role-gearmand" + chef.add_recipe "service::role-gearmand" #chef.json = JSON.parse(File.read("./deploy.json")) chef.log_level = :debug