diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..5b97963 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cookbook-openstack-ops-messaging.git diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..84e5b6d --- /dev/null +++ b/Berksfile @@ -0,0 +1,4 @@ +metadata + +cookbook "openstack-common", + git: "git://github.com/stackforge/cookbook-openstack-common.git" diff --git a/CHANGELOG.md b/CHANGELOG.md index d485638..fa14ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ -## 2013.1.0 +## 7.0.0 -* initial release +* Initial release intended for Grizzly-based OpenStack releases, + for use with Stackforge upstream repositories. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..04ef97e --- /dev/null +++ b/Gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gem "chef", "~> 11.4.4" +gem "json", "<= 1.7.7" # chef 11 dependency +gem "berkshelf", "~> 2.0.3" +gem "chefspec", "~> 1.3.0" +gem "foodcritic" +gem "strainer" +gem "tailor" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..947ca0e --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,222 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.2.13) + i18n (= 0.6.1) + multi_json (~> 1.0) + addressable (2.3.4) + akami (1.2.0) + gyoku (>= 0.4.0) + nokogiri (>= 1.4.0) + berkshelf (2.0.3) + activesupport (>= 3.2.0) + addressable (~> 2.3.4) + celluloid (>= 0.14.0) + chozo (>= 0.6.1) + faraday (>= 0.8.5) + hashie (>= 2.0.2) + minitar (~> 0.5.4) + retryable (~> 1.3.3) + ridley (~> 1.0.2) + solve (>= 0.4.4) + test-kitchen (>= 1.0.0.alpha7) + thor (~> 0.18.0) + builder (3.2.2) + celluloid (0.14.1) + timers (>= 1.0.0) + celluloid-io (0.14.1) + celluloid (>= 0.14.1) + nio4r (>= 0.4.5) + chef (11.4.4) + erubis + highline (>= 1.6.9) + json (>= 1.4.4, <= 1.7.7) + mixlib-authentication (>= 1.3.0) + mixlib-cli (~> 1.3.0) + mixlib-config (>= 1.1.2) + mixlib-log (>= 1.3.0) + mixlib-shellout + net-ssh (~> 2.6) + net-ssh-multi (~> 1.1.0) + ohai (>= 0.6.0) + rest-client (>= 1.0.4, < 1.7.0) + yajl-ruby (~> 1.1) + chefspec (1.3.1) + chef (>= 10.0) + erubis + fauxhai (>= 0.1.1, < 2.0) + minitest-chef-handler (>= 0.6.0) + rspec (~> 2.0) + chozo (0.6.1) + activesupport (>= 3.2.0) + hashie (>= 2.0.2) + multi_json (>= 1.3.0) + ci_reporter (1.8.4) + builder (>= 2.1.2) + coderay (1.0.9) + diff-lcs (1.2.4) + erubis (2.7.0) + faraday (0.8.7) + multipart-post (~> 1.1) + fauxhai (1.1.1) + httparty + net-ssh + ohai + ffi (1.9.0) + foodcritic (2.1.0) + erubis + gherkin (~> 2.11.7) + nokogiri (~> 1.5.4) + rak (~> 1.4) + treetop (~> 1.4.10) + yajl-ruby (~> 1.1.0) + gherkin (2.11.8) + multi_json (~> 1.3) + gssapi (1.0.3) + ffi (>= 1.0.1) + gyoku (1.0.0) + builder (>= 2.1.2) + hashie (2.0.5) + highline (1.6.19) + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) + httpclient (2.2.0.2) + httpi (0.9.7) + rack + i18n (0.6.1) + ipaddress (0.8.0) + json (1.6.1) + little-plugger (1.1.3) + log_switch (0.4.0) + logging (1.6.2) + little-plugger (>= 1.1.3) + method_source (0.8.1) + mime-types (1.23) + minitar (0.5.4) + minitest (4.7.4) + minitest-chef-handler (1.0.1) + chef + ci_reporter + minitest (~> 4.7.3) + mixlib-authentication (1.3.0) + mixlib-log + mixlib-cli (1.3.0) + mixlib-config (1.1.2) + mixlib-log (1.6.0) + mixlib-shellout (1.1.0) + multi_json (1.7.4) + multi_xml (0.5.4) + multipart-post (1.2.0) + net-http-persistent (2.8) + net-scp (1.1.1) + net-ssh (>= 2.6.5) + net-ssh (2.6.7) + net-ssh-gateway (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-multi (1.1) + net-ssh (>= 2.1.4) + net-ssh-gateway (>= 0.99.0) + nio4r (0.4.6) + nokogiri (1.5.9) + nori (1.1.5) + ohai (6.16.0) + ipaddress + mixlib-cli + mixlib-config + mixlib-log + mixlib-shellout + systemu + yajl-ruby + polyglot (0.3.3) + pry (0.9.12.2) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.4) + rack (1.5.2) + rak (1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + retryable (1.3.3) + ridley (1.0.2) + addressable + celluloid (~> 0.14.0) + celluloid-io (~> 0.14.0) + chozo (>= 0.6.0) + erubis + faraday (>= 0.8.4) + hashie (>= 2.0.2) + mixlib-authentication (>= 1.3.0) + net-http-persistent (>= 2.8) + net-ssh + retryable + solve (>= 0.4.4) + winrm (~> 1.1.0) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + rubyntlm (0.1.1) + safe_yaml (0.9.3) + savon (0.9.5) + akami (~> 1.0) + builder (>= 2.1.2) + gyoku (>= 0.4.0) + httpi (~> 0.9) + nokogiri (>= 1.4.0) + nori (~> 1.0) + wasabi (~> 1.0) + slop (3.4.5) + solve (0.5.0) + strainer (3.0.3) + berkshelf (~> 2.0) + systemu (2.5.2) + tailor (1.2.1) + log_switch (>= 0.3.0) + term-ansicolor (>= 1.0.5) + text-table (>= 1.2.2) + term-ansicolor (1.2.2) + tins (~> 0.8) + test-kitchen (1.0.0.alpha.7) + celluloid + mixlib-shellout + net-scp + net-ssh + pry + safe_yaml + thor + text-table (1.2.3) + thor (0.18.1) + timers (1.1.0) + tins (0.8.2) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + uuidtools (2.1.4) + wasabi (1.0.0) + nokogiri (>= 1.4.0) + winrm (1.1.2) + gssapi (~> 1.0.0) + httpclient (~> 2.2.0.2) + logging (~> 1.6.1) + nokogiri (~> 1.5.0) + rubyntlm (~> 0.1.1) + savon (= 0.9.5) + uuidtools (~> 2.1.2) + yajl-ruby (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + berkshelf (~> 2.0.3) + chef (~> 11.4.4) + chefspec (~> 1.3.0) + foodcritic + json (<= 1.7.7) + strainer + tailor diff --git a/README.md b/README.md index f14af02..3864ae5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Description # -This cookbook provides shared messaging configuration for the OpenStack **Grizzly** reference deployment provided by Chef for OpenStack. The http://github.com/mattray/chef-openstack-repo contains documentation for using this cookbook in the context of a full OpenStack deployment. It currently supports RabbitMQ and may eventually support other messaging technologies such as ActiveMQ or ZeroMQ. +This cookbook provides shared message queue configuration for the OpenStack **Grizzly** reference deployment provided by Chef for OpenStack. The http://github.com/mattray/chef-openstack-repo contains documentation for using this cookbook in the context of a full OpenStack deployment. It currently supports RabbitMQ and will soon other queues. # Requirements # @@ -14,56 +14,50 @@ Chef 11 with Ruby 1.9.x required. The following cookbooks are dependencies: -* openssl * rabbitmq +* openstack-common # Resources/Providers # None -# Recipes # - -## default ## - -Selects the messaging service selected by the attribute `['openstack']['messaging']['service']`. - -## rabbitmq ## - -Currently the only supported messaging service. Defaults to using the latest release from RabbitMQ.org. Override any attributes from the [rabbitmq cookbook](https://github.com/opscode-cookbooks/rabbitmq) to change behavior. - -# Attributes # - -* `openstack['role']['messaging']` - which role should other nodes search on to find the messaging service, defaults to 'os-ops-messaging' - -* `openstack['messaging']['service']` - which service to use, defaults to 'rabbitmq' -* `openstack['messaging']['host']` - messaging host, default is '0.0.0.0' -* `openstack['messaging']['port']` - messaging port, default is 5672 -* `openstack['messaging']['user']` - messaging user, default is 'rabbit' -* `openstack['messaging']['password']` - messaging password, defaults to secure generated password -* `openstack['messaging']['vhost']` - messaging vhost, defaults to '/nova' - # Templates # None +# Recipes # + +## server ## + +- message queue server configuration, selected by attributes + +## rabbitmq-server ## + +- configures the RabbitMQ server for OpenStack + +# Attributes # + +* `openstack['messaging']['server_role']` - the role name to search for the messaging service +* `openstack['messaging']['service']` - the messaging service to use; currently supports RabbitMQ + +* `openstack['messaging']['rabbitmq_options']['port']` - the port to use for RabbitMQ; default 5672 +* `openstack['messaging']['rabbitmq_options']['address']` - the address for RabbitMQ to listen on; default 0.0.0.0 +* `openstack['messaging']['rabbitmq_options']['user']` - the RabbitMQ user to use for OpenStack; default 'guest' +* `openstack['messaging']['rabbitmq_options']['vhost']` - the RabbitMQ vhost to use for OpenStack; default '/' + License and Author ================== | | | |:---------------------|:---------------------------------------------------| | **Author** | John Dewey () | -| **Author** | Justin Shepherd () | -| **Author** | Jason Cannavale () | -| **Author** | Ron Pedde () | -| **Author** | Joseph Breu () | -| **Author** | William Kelly () | -| **Author** | Darren Birkett () | -| **Author** | Evan Callicoat () | | **Author** | Matt Ray () | +| **Author** | Craig Tracey () | | | | -| **Copyright** | Copyright 2012, John Dewey | -| **Copyright** | Copyright (c) 2012-2013, Rackspace US, Inc. | -| **Copyright** | Copyright (c) 2012-2013, Opscode, Inc. | +| **Copyright** | Copyright (c) 2012, John Dewey | +| **Copyright** | Copyright (c) 2013, Opscode, Inc. | +| **Copyright** | Copyright (c) 2013, Craig Tracey | + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Strainerfile b/Strainerfile new file mode 100644 index 0000000..7e292b4 --- /dev/null +++ b/Strainerfile @@ -0,0 +1,5 @@ +# Strainerfile +tailor: bundle exec tailor +knife test: bundle exec knife cookbook test $COOKBOOK +foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK +chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec diff --git a/attributes/default.rb b/attributes/default.rb index 621e310..e2ef60f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,10 +1,11 @@ -default['openstack']['role']['messaging'] = 'os-ops-messaging' - +default['openstack']['messaging']['server_role'] = 'os-ops-messaging' default['openstack']['messaging']['service'] = 'rabbitmq' -default['openstack']['messaging']['host'] = node['rabbitmq']['address'] -default['openstack']['messaging']['port'] = node['rabbitmq']['port'] -default['openstack']['messaging']['user'] = 'rabbit' -default['openstack']['messaging']['password'] = nil -default['openstack']['messaging']['vhost'] = '/nova' - +case default['openstack']['messaging']['service'] +when "rabbitmq" + default['openstack']['messaging']['rabbitmq_options'] = {} + default['openstack']['messaging']['rabbitmq_options']['port'] = 5672 + default['openstack']['messaging']['rabbitmq_options']['address'] = "0.0.0.0" + default['openstack']['messaging']['rabbitmq_options']['user'] = "guest" + default['openstack']['messaging']['rabbitmq_options']['vhost'] = "/" +end diff --git a/metadata.rb b/metadata.rb index 9a31750..ead9c24 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,14 +3,14 @@ maintainer "Opscode, Inc." maintainer_email "matt@opscode.com" license "Apache 2.0" description "Provides the shared messaging configuration for Chef for OpenStack." -version "0.1.0" +version "7.0.0" -recipe "default", "Selects messaging service." -recipe "rabbitmq", "Configures RabbitMQ." +recipe "server", "Installs and configures server packages for messaging queue used by the deployment." +recipe "rabbitmq-server", "Installs and configures RabbitMQ and is called via the server recipe" %w{ ubuntu }.each do |os| supports os end -depends "openssl", ">= 1.0.2" -depends "rabbitmq", ">= 2.0.0" +depends "rabbitmq", ">= 2.1.0" +depends "openstack-common", "~> 0.2.4" diff --git a/recipes/default.rb b/recipes/default.rb index 10fc737..7f54e34 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -3,6 +3,7 @@ # Recipe:: default # # Copyright 2013, Opscode, Inc. +# Copyright 2013, Craig Tracey # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/rabbitmq-server.rb b/recipes/rabbitmq-server.rb new file mode 100644 index 0000000..95e9fbd --- /dev/null +++ b/recipes/rabbitmq-server.rb @@ -0,0 +1,68 @@ +# +# Cookbook Name:: openstack-ops-messaging +# Recipe:: rabbitmq-server +# +# Copyright 2012, John Dewey +# Copyright 2013, Opscode, Inc. +# Copyright 2013, Craig Tracey +# +# +# 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::Recipe + include ::Openstack +end + +node.set["rabbitmq"]["port"] = node["openstack"]["messaging"]["rabbitmq_options"]["port"] +node.set["rabbitmq"]["address"] = node["openstack"]["messaging"]["rabbitmq_options"]["address"] +node.set["rabbitmq"]["use_distro_version"] = true + +include_recipe "rabbitmq::default" +include_recipe "rabbitmq::mgmt_console" + +rabbit_password = user_password "rabbit" +rabbit_user = node["openstack"]["messaging"]["rabbitmq_options"]["user"] +rabbit_vhost = node["openstack"]["messaging"]["rabbitmq_options"]["vhost"] + +# remove the guest user if we dont need it +rabbitmq_user "remove rabbit guest user" do + user 'guest' + action :delete + not_if { rabbit_user.eql?('guest') } +end + +rabbitmq_user "add openstack rabbit user" do + user rabbit_user + password rabbit_password + action :add +end + +rabbitmq_vhost "add openstack rabbit vhost" do + vhost rabbit_vhost + action :add +end + +rabbitmq_user "set openstack user permissions" do + user rabbit_user + vhost rabbit_vhost + permissions '.* .* .*' + action :set_permissions +end + +# Necessary for graphing. +rabbitmq_user "set rabbit administrator tag" do + user rabbit_user + tag "administrator" + action :set_tags +end diff --git a/recipes/rabbitmq.rb b/recipes/rabbitmq.rb deleted file mode 100644 index e867748..0000000 --- a/recipes/rabbitmq.rb +++ /dev/null @@ -1,58 +0,0 @@ -# -# Cookbook Name:: openstack-ops-messaging -# Recipe:: rabbitmq -# -# Copyright 2013, Opscode, Inc. -# Copyright 2012, John Dewey -# -# 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::Recipe.send(:include, Opscode::OpenSSL::Password) - -node.set_unless['openstack']['messaging']['password'] = secure_password -node.set_unless['rabbitmq']['address'] = '0.0.0.0' -node.set_unless['rabbitmq']['port'] = 5672 - -include_recipe "rabbitmq" -include_recipe "rabbitmq::mgmt_console" - -user = node['openstack']['messaging']['user'] -vhost = node['openstack']['messaging']['vhost'] - -# remove the guest user -rabbitmq_user 'guest' do - action :delete - not_if { user.eql?('guest') } -end - -rabbitmq_user user do - password node['openstack']['messaging']['password'] - action :add -end - -rabbitmq_vhost vhost do - action :add -end - -rabbitmq_user user do - vhost vhost - permissions ".* .* .*" - action :set_permissions -end - -# Necessary for graphing. -rabbitmq_user user do - tag "administrator" - action :set_tags -end diff --git a/recipes/server.rb b/recipes/server.rb new file mode 100644 index 0000000..609672f --- /dev/null +++ b/recipes/server.rb @@ -0,0 +1,21 @@ +# +# Cookbook Name:: openstack-ops-messaging +# Recipe:: server +# +# Copyright 2013, Opscode, Inc. +# Copyright 2013, Craig Tracey +# +# 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 "openstack-ops-messaging::#{node['openstack']['messaging']['service']}-server" diff --git a/spec/default_spec.rb b/spec/default_spec.rb new file mode 100644 index 0000000..b389a25 --- /dev/null +++ b/spec/default_spec.rb @@ -0,0 +1,4 @@ +require_relative "spec_helper" + +describe "openstack-ops-messaging::default" do +end diff --git a/spec/rabbitmq-server_spec.rb b/spec/rabbitmq-server_spec.rb new file mode 100644 index 0000000..f77b3f6 --- /dev/null +++ b/spec/rabbitmq-server_spec.rb @@ -0,0 +1,119 @@ +require_relative 'spec_helper' + +describe 'openstack-ops-messaging::rabbitmq-server' do + describe 'ubuntu' do + before do + messaging_stubs + @chef_run = ::ChefSpec::ChefRunner.new(::UBUNTU_OPTS) do |node| + node.set['lsb'] = {'codename' => 'precise'} + node.set['openstack']= {'messaging' => { + 'service' => 'rabbitmq', + 'rabbitmq_options' => { + 'user' => 'openstack_rabbit_user', + 'vhost' => '/openstack_rabbit_vhost' + } + } + } + node.set['rabbitmq'] = { + 'erlang_cookie_path' => '/path/to/nowhere' + } + end + + @rabbitmq_user_mock = double "rabbitmq_user" + @rabbitmq_vhost_mock = double "rabbitmq_vhost" + end + + it "rabbitmq-server basic test" do + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + + expect(@chef_run).to include_recipe "openstack-ops-messaging::rabbitmq-server" + expect(@chef_run).to include_recipe "rabbitmq::default" + expect(@chef_run).to include_recipe "rabbitmq::mgmt_console" + end + + it "removes the rabbit guest user" do + ::Chef::Recipe.any_instance.stub(:rabbitmq_user) + ::Chef::Recipe.any_instance.should_receive(:rabbitmq_user). + with("remove rabbit guest user") do |&arg| + @rabbitmq_user_mock.should_receive(:user). + with "guest" + @rabbitmq_user_mock.should_receive(:action). + with :delete + @rabbitmq_user_mock.should_receive(:not_if) + + @rabbitmq_user_mock.instance_eval &arg + end + + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + end + + it "adds the openstack rabbit user" do + ::Chef::Recipe.any_instance.stub(:rabbitmq_user) + ::Chef::Recipe.any_instance.should_receive(:rabbitmq_user). + with("add openstack rabbit user") do |&arg| + @rabbitmq_user_mock.should_receive(:user). + with "openstack_rabbit_user" + @rabbitmq_user_mock.should_receive(:password). + with "rabbitpassword" + @rabbitmq_user_mock.should_receive(:action). + with :add + + @rabbitmq_user_mock.instance_eval &arg + end + + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + end + + it "adds the openstack rabbit vhost" do + ::Chef::Recipe.any_instance.stub(:rabbitmq_vhost) + ::Chef::Recipe.any_instance.should_receive(:rabbitmq_vhost). + with("add openstack rabbit vhost") do |&arg| + @rabbitmq_vhost_mock.should_receive(:vhost). + with "/openstack_rabbit_vhost" + @rabbitmq_vhost_mock.should_receive(:action). + with :add + + @rabbitmq_vhost_mock.instance_eval &arg + end + + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + end + + it "set openstack user permissions" do + ::Chef::Recipe.any_instance.stub(:rabbitmq_user) + ::Chef::Recipe.any_instance.should_receive(:rabbitmq_user). + with("set openstack user permissions") do |&arg| + @rabbitmq_user_mock.should_receive(:user). + with "openstack_rabbit_user" + @rabbitmq_user_mock.should_receive(:vhost). + with "/openstack_rabbit_vhost" + @rabbitmq_user_mock.should_receive(:permissions). + with ".* .* .*" + @rabbitmq_user_mock.should_receive(:action). + with :set_permissions + + @rabbitmq_user_mock.instance_eval &arg + end + + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + end + + it "set rabbit administrator tag" do + ::Chef::Recipe.any_instance.stub(:rabbitmq_user) + ::Chef::Recipe.any_instance.should_receive(:rabbitmq_user). + with("set rabbit administrator tag") do |&arg| + @rabbitmq_user_mock.should_receive(:user). + with "openstack_rabbit_user" + @rabbitmq_user_mock.should_receive(:tag). + with "administrator" + @rabbitmq_user_mock.should_receive(:action). + with :set_tags + + @rabbitmq_user_mock.instance_eval &arg + end + + @chef_run.converge "openstack-ops-messaging::rabbitmq-server" + end + + end +end diff --git a/spec/server_spec.rb b/spec/server_spec.rb new file mode 100644 index 0000000..bb4bcca --- /dev/null +++ b/spec/server_spec.rb @@ -0,0 +1,27 @@ +require_relative 'spec_helper' + +describe 'openstack-ops-messaging::server' do + describe 'ubuntu' do + + before do + messaging_stubs + end + + it "select 'rabbitmq-server' recipe" do + chef_run = ::ChefSpec::ChefRunner.new(::UBUNTU_OPTS) do |node| + node.set['lsb'] = {'codename' => 'precise'} + node.set['openstack'] = { + 'messaging' => { + 'service' => 'rabbitmq' + } + } + node.set['rabbitmq'] = { + 'erlang_cookie_path' => '/path/to/nowhere' + } + end + chef_run.converge 'openstack-ops-messaging::server' + expect(chef_run).to include_recipe "openstack-ops-messaging::rabbitmq-server" + end + + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..16f32bd --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,12 @@ +require "chefspec" + +::LOG_LEVEL = :fatal +::UBUNTU_OPTS = { + :platform => "ubuntu", + :version => "12.04", + :log_level => ::LOG_LEVEL +} + +def messaging_stubs + ::Chef::Recipe.any_instance.stub(:user_password).and_return("rabbitpassword") +end