Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow nova::rabbitmq to be disabled.

This commit adds the parameter enabled to the class nova::rabbitmq.
This parameter was added to allow this service to be deployed as
passive in an active-passive HA cluster.

This commit also adds test coverage to the nova::rabbitmq class.

It also adds the rabbitmq module as a dependency.y
  • Loading branch information...
commit 14a2a0f54dd25e3ecab012f6bbbb4b91f256e7b2 1 parent a81bf7b
@bodepd bodepd authored
View
1  .fixtures.yml
@@ -5,5 +5,6 @@ fixtures:
"mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"sysctl": "git://github.com/duritong/puppet-sysctl.git"
+ "rabbitmq": "git://github.com/puppetlabs/puppetlabs-rabbitmq.git"
symlinks:
"nova": "#{source_dir}"
View
51 manifests/rabbitmq.pp
@@ -6,36 +6,47 @@
$userid='guest',
$password='guest',
$port='5672',
- $virtual_host='/'
+ $virtual_host='/',
+ $enabled = true
) {
# only configure nova after the queue is up
Class['rabbitmq::service'] -> Anchor<| title == 'nova-start' |>
- if $userid == 'guest' {
- $delete_guest_user = false
- } else {
- $delete_guest_user = true
- rabbitmq_user { $userid:
- admin => true,
- password => $password,
- provider => 'rabbitmqctl',
- require => Class['rabbitmq::server'],
+ if ($enabled) {
+ if $userid == 'guest' {
+ $delete_guest_user = false
+ } else {
+ $delete_guest_user = true
+ rabbitmq_user { $userid:
+ admin => true,
+ password => $password,
+ provider => 'rabbitmqctl',
+ require => Class['rabbitmq::server'],
+ }
+ # I need to figure out the appropriate permissions
+ rabbitmq_user_permissions { "${userid}@${virtual_host}":
+ configure_permission => '.*',
+ write_permission => '.*',
+ read_permission => '.*',
+ provider => 'rabbitmqctl',
+ }->Anchor<| title == 'nova-start' |>
}
- # I need to figure out the appropriate permissions
- rabbitmq_user_permissions { "${userid}@${virtual_host}":
- configure_permission => '.*',
- write_permission => '.*',
- read_permission => '.*',
- provider => 'rabbitmqctl',
- }->Anchor<| title == 'nova-start' |>
+ $service_ensure = 'running'
+ } else {
+ $service_ensure = 'stopped'
}
+
class { 'rabbitmq::server':
+ service_ensure => $service_ensure,
port => $port,
delete_guest_user => $delete_guest_user,
}
- rabbitmq_vhost { $virtual_host:
- provider => 'rabbitmqctl',
- require => Class['rabbitmq::server'],
+
+ if ($enabled) {
+ rabbitmq_vhost { $virtual_host:
+ provider => 'rabbitmqctl',
+ require => Class['rabbitmq::server'],
+ }
}
}
View
79 spec/classes/nova_rabbitmq_spec.rb
@@ -0,0 +1,79 @@
+require 'spec_helper'
+
+describe 'nova::rabbitmq' do
+
+ let :facts do
+ {:puppetversion => '2.7'}
+ end
+
+ describe 'with defaults' do
+
+ it 'should contain all of the default resources' do
+
+ should contain_class('rabbitmq::server').with(
+ :service_ensure => 'running',
+ :port => '5672',
+ :delete_guest_user => false
+ )
+
+ should contain_rabbitmq_vhost('/').with(
+ :provider => 'rabbitmqctl'
+ )
+ end
+
+ end
+
+ describe 'when a rabbitmq user is specified' do
+
+ let :params do
+ {
+ :userid => 'dan',
+ :password => 'pass'
+ }
+ end
+
+ it 'should contain user and permissions' do
+
+ should contain_rabbitmq_user('dan').with(
+ :admin => true,
+ :password => 'pass',
+ :provider => 'rabbitmqctl'
+ )
+
+ should contain_rabbitmq_user_permissions('dan@/').with(
+ :configure_permission => '.*',
+ :write_permission => '.*',
+ :read_permission => '.*',
+ :provider => 'rabbitmqctl'
+ )
+
+ end
+
+ end
+
+ describe 'when disabled' do
+ let :params do
+ {
+ :userid => 'dan',
+ :password => 'pass',
+ :enabled => false
+ }
+ end
+
+ it 'should be disabled' do
+
+ should_not contain_rabbitmq_user('dan')
+ should_not contain_rabbitmq_user_permissions('dan@/')
+ should contain_class('rabbitmq::server').with(
+ :service_ensure => 'stopped',
+ :port => '5672',
+ :delete_guest_user => false
+ )
+
+ should_not contain_rabbitmq_vhost('/')
+
+ end
+ end
+
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.