Update from upstream version 2.0.1 to 2.1.0 and merge our changes. All tests are green.

This commit is contained in:
Vladmir Sharhsov(warpc) 2013-07-03 14:12:45 +04:00 committed by Sergey Vasilenko
parent b1153b05cc
commit 24310f6bac
11 changed files with 109 additions and 41 deletions

View File

@ -1,3 +1,8 @@
* 2013-04-11 2.1.0
- remove puppetversion from rabbitmq.config template
- add cluster support
- escape resource names in regexp
* 2012-07-31 Jeff McCune <jeff@puppetlabs.com> 2.0.2
- Re-release 2.0.1 with $EDITOR droppings cleaned up

View File

@ -1,5 +1,5 @@
name 'puppetlabs-rabbitmq'
version '2.0.2'
version '2.1.0'
source 'git://github.com/puppetlabs/puppetlabs-rabbitmq.git'
author 'puppetlabs'
license 'Apache'
@ -9,4 +9,4 @@ project_page 'http://github.com/puppetlabs/puppetlabs-rabbitmq'
## Add dependencies, if any:
dependency 'puppetlabs/stdlib', '>= 2.0.0'
dependency 'puppetlabs/apt', '>= 0.0.3'
dependency 'puppetlabs/apt', '>= 0.0.3'

View File

@ -37,6 +37,20 @@ Class for installing rabbitmq-server:
delete_guest_user => true,
}
### Clustering
To use RabbitMQ clustering and H/A facilities, use the rabbitmq::server
parameters `config_cluster` and `cluster_disk_nodes`, e.g.:
class { 'rabbitmq::server':
config_cluster => true,
cluster_disk_nodes => ['rabbit1', 'rabbit2'],
}
Currently all cluster nodes are registered as disk nodes (not ram).
**NOTE:** You still need to use `x-ha-policy: all` in your client
applications for any particular queue to take advantage of H/A, this module
merely clusters RabbitMQ instances.
## Native Types

View File

@ -1,6 +1,7 @@
require 'puppet'
Puppet::Type.type(:rabbitmq_user).provide(:rabbitmqctl) do
#TODO: change optional_commands -> commands when puppet >= 3.0
optional_commands :rabbitmqctl => 'rabbitmqctl'
defaultfor :feature => :posix

View File

@ -1,5 +1,6 @@
Puppet::Type.type(:rabbitmq_user_permissions).provide(:rabbitmqctl) do
#TODO: change optional_commands -> commands when puppet >= 3.0
optional_commands :rabbitmqctl => 'rabbitmqctl'
defaultfor :feature=> :posix

View File

@ -1,5 +1,6 @@
Puppet::Type.type(:rabbitmq_vhost).provide(:rabbitmqctl) do
#TODO: change optional_commands -> commands when puppet >= 3.0
optional_commands :rabbitmqctl => 'rabbitmqctl'
defaultfor :feature => :posix

View File

@ -13,6 +13,15 @@
# [*node_ip_address*] - ip address for rabbitmq to bind to
# [*config*] - contents of config file
# [*env_config*] - contents of env-config file
# [*config_cluster*] - whether to configure a RabbitMQ cluster
# [*cluster_disk_nodes*] - which nodes to cluster with (including the current one)
# [*erlang_cookie*] - erlang cookie, must be the same for all nodes in a cluster
# [*wipe_db_on_cookie_change*] - whether to wipe the RabbitMQ data if the specified
# erlang_cookie differs from the current one. This is a sad parameter: actually,
# if the cookie indeed differs, then wiping the database is the *only* thing you
# can do. You're only required to set this parameter to true as a sign that you
# realise this.
# Requires:
# stdlib
# Sample Usage:
@ -23,8 +32,6 @@
# [Remember: No empty lines between comments and class definition]
class rabbitmq::server(
$port = '5672',
$inet_dist_listen_min = '41055',
$inet_dist_listen_max = '41055',
$delete_guest_user = false,
$package_name = 'rabbitmq-server',
$version = 'UNSET',
@ -32,11 +39,15 @@ class rabbitmq::server(
$service_ensure = 'running',
$config_stomp = false,
$stomp_port = '6163',
$config_cluster = false,
$cluster_disk_nodes = [],
$node_ip_address = 'UNSET', #getvar("::ipaddress_${::internal_interface}"),
$config='UNSET',
$config_cluster = false,
$cluster_disk_nodes = [],
$env_config='UNSET'
$env_config='UNSET',
$erlang_cookie='EOKOWXQREETZSHFNTPEY',
$wipe_db_on_cookie_change=false,
$inet_dist_listen_min = '41055',
$inet_dist_listen_max = '41055',
) {
validate_bool($delete_guest_user, $config_stomp)
@ -62,7 +73,6 @@ class rabbitmq::server(
}
$plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version_real}/plugins"
$erlang_cookie_content = 'EOKOWXQREETZSHFNTPEY'
if $::osfamily == 'RedHat' {
package { 'qpid-cpp-server':
@ -91,9 +101,37 @@ class rabbitmq::server(
owner => '0',
group => '0',
mode => '0644',
require => Package[$package_name],
notify => Class['rabbitmq::service'],
require => File['erlang_cookie']
}
if $config_cluster {
file { 'erlang_cookie':
path =>"/var/lib/rabbitmq/.erlang.cookie",
owner => rabbitmq,
group => rabbitmq,
mode => '0400',
content => $erlang_cookie,
replace => true,
before => File['rabbitmq.config'],
require => Exec['wipe_db'], # require => Exec['rabbitmq_stop']
}
# require authorize_cookie_change
if $wipe_db_on_cookie_change {
exec { 'wipe_db':
command => '/etc/init.d/rabbitmq-server stop; /bin/rm -rf /var/lib/rabbitmq/mnesia',
require => Package[$package_name],
unless => "/bin/grep -qx ${erlang_cookie} /var/lib/rabbitmq/.erlang.cookie"
}
} else {
exec { 'wipe_db':
command => '/bin/false "Cookie must be changed but wipe_db is false"', # If the cookie doesn't match, just fail.
require => Package[$package_name],
unless => "/bin/grep -qx ${erlang_cookie} /var/lib/rabbitmq/.erlang.cookie"
}
}
}
file { 'rabbitmq-env.config':
ensure => file,
@ -139,23 +177,6 @@ class rabbitmq::server(
ensure => $service_ensure,
}
exec { 'rabbitmq_stop':
command => '/etc/init.d/rabbitmq-server stop; /bin/rm -rf /var/lib/rabbitmq/mnesia',
require => Package[$package_name],
unless => "/bin/grep -qx ${erlang_cookie_content} /var/lib/rabbitmq/.erlang.cookie"
}
file { 'erlang_cookie':
path =>"/var/lib/rabbitmq/.erlang.cookie",
owner => rabbitmq,
group => rabbitmq,
mode => '0400',
content => $erlang_cookie_content,
replace => true,
#notify => Class['rabbitmq::service'],
require => Exec['rabbitmq_stop'],
}
if $delete_guest_user {
# delete the default guest user
rabbitmq_user{ 'guest':

View File

@ -68,7 +68,7 @@ describe 'rabbitmq::server' do
describe 'not configuring stomp by default' do
it 'should not specify stomp parameters in rabbitmq.config' do
verify_contents(subject, 'rabbitmq.config',
['[].'])
['[','].'])
end
end
@ -80,9 +80,38 @@ describe 'rabbitmq::server' do
end
it 'should specify stomp port in rabbitmq.config' do
verify_contents(subject, 'rabbitmq.config',
['[ {rabbitmq_stomp, [{tcp_listeners, [5679]} ]} ].'])
['[','{rabbitmq_stomp, [{tcp_listeners, [5679]} ]}','].'])
end
end
describe 'configuring cluster' do
let :params do
{ :config_cluster => true,
:cluster_disk_nodes => ['hare-1', 'hare-2']
}
end
it 'should specify cluster nodes in rabbitmq.config' do
verify_contents(subject, 'rabbitmq.config',
['[',"{rabbit, [{cluster_nodes, ['rabbit@hare-1', 'rabbit@hare-2']}]}", '].'])
end
it 'should have the default erlang cookie' do
verify_contents(subject, 'erlang_cookie',
['EOKOWXQREETZSHFNTPEY'])
end
end
describe 'specifying custom erlang cookie in cluster mode' do
let :params do
{ :config_cluster => true,
:erlang_cookie => 'YOKOWXQREETZSHFNTPEY' }
end
it 'should set .erlang.cookie to the specified value' do
verify_contents(subject, 'erlang_cookie',
['YOKOWXQREETZSHFNTPEY'])
end
end
end

View File

@ -14,6 +14,7 @@ describe Puppet::Type.type(:rabbitmq_user) do
@user[:password].should == 'foo'
end
it 'should require a password' do
# TODO: change ArgumentError -> Puppet::ResourceError when when puppet >= 3.0
expect {
Puppet::Type.type(:rabbitmq_user).new(:name => 'foo')
}.to raise_error(ArgumentError, /must set password/)

View File

@ -1,17 +1,12 @@
% This file managed by Puppet <%= puppetversion %>
% This file managed by Puppet
% Template Path: <%= module_name %>/templates/rabbitmq.config
[
<% if config_cluster -%>
{rabbit, [{cluster_nodes, [<%= cluster_disk_nodes.map { |n| "\'rabbit@#{n}\'" }.join(', ') %>]}]}
<% if config_stomp -%>
% Configure the Stomp Plugin listening port
,{rabbitmq_stomp, [{tcp_listeners, [<%= stomp_port %>]} ]}
<% end -%>
<% else -%>
<% if config_stomp -%>
% Configure the Stomp Plugin listening port
{rabbitmq_stomp, [{tcp_listeners, [<%= stomp_port %>]} ]}
<% end -%>
{rabbit, [{cluster_nodes, [<%= cluster_disk_nodes.map { |n| "\'rabbit@#{n}\'" }.join(', ') %>]}]}<% if config_stomp -%>,<% end %>
<% end -%>
<% if config_stomp -%>
% Configure the Stomp Plugin listening port
{rabbitmq_stomp, [{tcp_listeners, [<%= stomp_port %>]} ]}
<% end -%>
].
% EOF
% EOF