Use upstream puppetlabs-rabbitmq
We want no more downstream efforts for the module. All patches shall be sent upstream only now. Closes-bug: #1534560 Change-Id: I82753a625672635de2ddd340d60d7fbe344ad50a Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
This commit is contained in:
parent
701629f046
commit
b97ffa5499
|
@ -37,3 +37,4 @@ puppet/sysctl
|
|||
puppet/tftp
|
||||
puppet/vcsrepo
|
||||
puppet/xinetd
|
||||
puppet/rabbitmq
|
||||
|
|
|
@ -195,3 +195,9 @@ mod 'datacat',
|
|||
mod 'mcollective',
|
||||
:git => 'https://github.com/fuel-infra/puppet-mcollective.git',
|
||||
:ref => 'v2.1.1'
|
||||
|
||||
# Pull in puppetlabs-rabbitmq
|
||||
# FIXME(bogdando) We need the 5.3.1-dc0964d. Use the 5.3.2 once released.
|
||||
mod 'rabbitmq',
|
||||
:git => 'https://github.com/puppetlabs/puppetlabs-rabbitmq.git',
|
||||
:ref => 'dc0964d'
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
pkg/
|
||||
Gemfile.lock
|
||||
vendor/
|
||||
spec/fixtures/
|
||||
.vagrant/
|
||||
.bundle/
|
||||
coverage/
|
||||
.idea/
|
||||
*.iml
|
|
@ -142,9 +142,27 @@ class nailgun::rabbitmq (
|
|||
'tcp_listen_options' => $rabbit_tcp_listen_options,
|
||||
},
|
||||
|
||||
config_rabbitmq_management_variables => $rabbitmq_management_variables,
|
||||
config_management_variables => $rabbitmq_management_variables,
|
||||
}
|
||||
|
||||
# NOTE(bogdando) retries for the rabbitmqadmin curl command, unmerged MODULES-1650
|
||||
Staging::File <| title == 'rabbitmqadmin' |> {
|
||||
tries => 30,
|
||||
try_sleep => 6,
|
||||
}
|
||||
# TODO(bogdando) contribute this to puppetlabs-rabbitmq
|
||||
# Start epmd as rabbitmq so it doesn't run as root when installing plugins
|
||||
exec { 'epmd_daemon':
|
||||
command => 'epmd -daemon',
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin',
|
||||
user => 'rabbitmq',
|
||||
group => 'rabbitmq',
|
||||
unless => 'pgrep epmd',
|
||||
}
|
||||
# Make sure the various providers have their requirements in place.
|
||||
Class['::rabbitmq::install'] -> Exec['epmd_daemon']
|
||||
-> Rabbitmq_plugin<| |> -> Rabbitmq_exchange<| |>
|
||||
|
||||
Anchor['nailgun::rabbitmq start'] ->
|
||||
Class['::rabbitmq'] ->
|
||||
Anchor['nailgun::rabbitmq end']
|
||||
|
|
|
@ -92,7 +92,7 @@ if $queue_provider == 'rabbitmq' {
|
|||
'disk_free_limit' => '5000000', # Corosync checks for disk space, reduce rabbitmq check to 5M see LP#1493520 comment #15
|
||||
}
|
||||
)
|
||||
$config_rabbitmq_management_variables = hiera('rabbit_config_management_variables',
|
||||
$config_management_variables = hiera('rabbit_config_management_variables',
|
||||
{
|
||||
'rates_mode' => 'none',
|
||||
'listener' => "[{port, 15672}, {ip,\"${management_bind_ip_address}\"}]",
|
||||
|
@ -138,11 +138,29 @@ if $queue_provider == 'rabbitmq' {
|
|||
version => $version,
|
||||
node_ip_address => $rabbitmq_bind_ip_address,
|
||||
config_kernel_variables => $config_kernel_variables,
|
||||
config_rabbitmq_management_variables => $config_rabbitmq_management_variables,
|
||||
config_management_variables => $config_management_variables,
|
||||
config_variables => $config_variables,
|
||||
environment_variables => $environment_variables,
|
||||
}
|
||||
|
||||
# NOTE(bogdando) retries for the rabbitmqadmin curl command, unmerged MODULES-1650
|
||||
Staging::File <| title == 'rabbitmqadmin' |> {
|
||||
tries => 30,
|
||||
try_sleep => 6,
|
||||
}
|
||||
# TODO(bogdando) contribute this to puppetlabs-rabbitmq
|
||||
# Start epmd as rabbitmq so it doesn't run as root when installing plugins
|
||||
exec { 'epmd_daemon':
|
||||
command => 'epmd -daemon',
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin',
|
||||
user => 'rabbitmq',
|
||||
group => 'rabbitmq',
|
||||
unless => 'pgrep epmd',
|
||||
}
|
||||
# Make sure the various providers have their requirements in place.
|
||||
Class['::rabbitmq::install'] -> Exec['epmd_daemon']
|
||||
-> Rabbitmq_plugin<| |> -> Rabbitmq_exchange<| |>
|
||||
|
||||
if ($use_pacemaker) {
|
||||
# Install rabbit-fence daemon
|
||||
class { 'cluster::rabbitmq_fence':
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
fixtures:
|
||||
symlinks:
|
||||
rabbitmq: "#{source_dir}"
|
||||
stdlib: "#{source_dir}/../stdlib"
|
||||
apt: "#{source_dir}/../apt"
|
||||
staging: "#{source_dir}/../staging"
|
|
@ -1,8 +0,0 @@
|
|||
.pkg
|
||||
Gemfile.lock
|
||||
vendor
|
||||
spec/fixtures
|
||||
.rspec_system
|
||||
.bundle
|
||||
.vagrant
|
||||
.*sw*
|
|
@ -1,35 +0,0 @@
|
|||
---
|
||||
default_set: 'centos-64-x64'
|
||||
sets:
|
||||
'centos-59-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'centos-59-x64'
|
||||
'centos-64-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'centos-64-x64'
|
||||
'fedora-18-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'fedora-18-x64'
|
||||
'debian-607-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'debian-607-x64'
|
||||
'debian-70rc1-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'debian-70rc1-x64'
|
||||
'ubuntu-server-10044-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'ubuntu-server-10044-x64'
|
||||
'ubuntu-server-12042-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'ubuntu-server-12042-x64'
|
||||
'sles-11sp1-x64':
|
||||
nodes:
|
||||
"main.foo.vm":
|
||||
prefab: 'sles-11sp1-x64'
|
|
@ -1,13 +0,0 @@
|
|||
---
|
||||
language: ruby
|
||||
bundler_args: --without system_tests
|
||||
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 3.0"
|
||||
- rvm: 2.0.0
|
||||
env: PUPPET_GEM_VERSION="~> 3.0"
|
||||
notifications:
|
||||
email: false
|
|
@ -1,139 +0,0 @@
|
|||
2014-08-20 - Version 4.1.0
|
||||
|
||||
Summary:
|
||||
|
||||
This release adds several new features, fixes bugs, and improves tests and
|
||||
documentation.
|
||||
|
||||
Features:
|
||||
- Autorequire the rabbitmq-server service in the rabbitmq_vhost type
|
||||
- Add credentials to rabbitmqadmin URL
|
||||
- Added $ssl_only parameter to rabbitmq, rabbitmq::params, and
|
||||
rabbitmq::config
|
||||
- Added property tags to rabbitmq_user provider
|
||||
|
||||
Bugfixes:
|
||||
- Fix erroneous commas in rabbitmq::config
|
||||
- Use correct ensure value for the rabbitmq_stomp rabbitmq_plugin
|
||||
- Set HOME env variable to nil when leveraging rabbitmq to remove type error
|
||||
from Python script
|
||||
- Fix location for rabbitmq-plugins for RHEL
|
||||
- Remove validation for package_source to allow it to be set to false
|
||||
- Allow LDAP auth configuration without configuring stomp
|
||||
- Added missing $ssl_verify and $ssl_fail_if_no_peer_cert to rabbitmq::config
|
||||
|
||||
2014-05-16 - Version 4.0.0
|
||||
|
||||
Summary:
|
||||
|
||||
This release includes many new features and bug fixes. With the exception of
|
||||
erlang management this should be backwards compatible with 3.1.0.
|
||||
|
||||
Backwards-incompatible Changes:
|
||||
- erlang_manage was removed. You will need to manage erlang separately. See
|
||||
the README for more information on how to configure this.
|
||||
|
||||
Features:
|
||||
- Improved SSL support
|
||||
- Add LDAP support
|
||||
- Add ability to manage RabbitMQ repositories
|
||||
- Add ability to manage Erlang kernel configuration options
|
||||
- Improved handling of user tags
|
||||
- Use nanliu-staging module instead of hardcoded 'curl'
|
||||
- Switch to yum or zypper provider instead of rpm
|
||||
- Add ability to manage STOMP plugin installation.
|
||||
- Allow empty permission fields
|
||||
- Convert existing system tests to beaker acceptance tests.
|
||||
|
||||
Bugfixes:
|
||||
- exchanges no longer recreated on each puppet run if non-default vhost is used
|
||||
- Allow port to be UNSET
|
||||
- Re-added rabbitmq::server class
|
||||
- Deprecated previously unused manage_service variable in favor of
|
||||
service_manage
|
||||
- Use correct key for rabbitmq apt::source
|
||||
- config_mirrored_queues variable removed
|
||||
- It previously did nothing, will now at least throw a warning if you try to
|
||||
use it
|
||||
- Remove unnecessary dependency on Class['rabbitmq::repo::rhel'] in
|
||||
rabbitmq::install
|
||||
|
||||
|
||||
2013-09-14 - Version 3.1.0
|
||||
|
||||
Summary:
|
||||
|
||||
This release focuses on a few small (but critical) bugfixes as well as extends
|
||||
the amount of custom RabbitMQ configuration you can do with the module.
|
||||
|
||||
Features:
|
||||
- You can now change RabbitMQ 'Config Variables' via the parameter `config_variables`.
|
||||
- You can now change RabbitMQ 'Environment Variables' via the parameter `environment_variables`.
|
||||
- ArchLinux support added.
|
||||
|
||||
Fixes:
|
||||
- Make use of the user/password parameters in rabbitmq_exchange{}
|
||||
- Correct the read/write parameter order on set_permissions/list_permissions as
|
||||
they were reversed.
|
||||
- Make the module pull down 3.1.5 by default.
|
||||
|
||||
* 2013-07-18 3.0.0
|
||||
Summary:
|
||||
This release heavily refactors the RabbitMQ and changes functionality in
|
||||
several key ways. Please pay attention to the new README.md file for
|
||||
details of how to interact with the class now. Puppet 3 and RHEL are
|
||||
now fully supported. The default version of RabbitMQ has changed to
|
||||
a 3.x release.
|
||||
|
||||
Bugfixes:
|
||||
- Improve travis testing options.
|
||||
- Stop reimporting the GPG key on every run on RHEL and Debian.
|
||||
- Fix documentation to make it clear you don't have to set provider => each time.
|
||||
- Reference the standard rabbitmq port in the documentation instead of a custom port.
|
||||
- Fixes to the README formatting.
|
||||
|
||||
Features:
|
||||
- Refactor the module to fix RHEL support. All interaction with the module
|
||||
is now done through the main rabbitmq class.
|
||||
- Add support for mirrored queues (Only on Debian family distributions currently)
|
||||
- Add rabbitmq_exchange provider (using rabbitmqadmin)
|
||||
- Add new `rabbitmq` class parameters:
|
||||
- `manage_service`: Boolean to choose if Puppet should manage the service. (For pacemaker/HA setups)
|
||||
- Add SuSE support.
|
||||
|
||||
Incompatible Changes:
|
||||
- Rabbitmq::server has been removed and is now rabbitmq::config. You should
|
||||
not use this class directly, only via the main rabbitmq class.
|
||||
|
||||
* 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
|
||||
|
||||
* 2012-05-03 2.0.0
|
||||
- added support for new-style admin users
|
||||
- added support for rabbitmq 2.7.1
|
||||
|
||||
* 2011-06-14 Dan Bode <dan@Puppetlabs.com> 2.0.0rc1
|
||||
- Massive refactor:
|
||||
- added native types for user/vhost/user_permissions
|
||||
- added apt support for vendor packages
|
||||
- added smoke tests
|
||||
|
||||
* 2011-04-08 Jeff McCune <jeff@puppetlabs.com> 1.0.4
|
||||
- Update module for RabbitMQ 2.4.1 and rabbitmq-plugin-stomp package.
|
||||
|
||||
2011-03-24 1.0.3
|
||||
- Initial release to the forge. Reviewed by Cody. Whitespace is good.
|
||||
|
||||
2011-03-22 1.0.2
|
||||
- Whitespace only fix again... ack '\t' is my friend...
|
||||
|
||||
2011-03-22 1.0.1
|
||||
- Whitespace only fix.
|
||||
|
||||
2011-03-22 1.0.0
|
||||
- Initial Release. Manage the package, file and service.
|
|
@ -1,198 +0,0 @@
|
|||
## 2014-12-22 - Version 5.0.0
|
||||
|
||||
### Summary
|
||||
|
||||
This release fixes a longstanding security issue where the rabbitmq
|
||||
erlang cookie was exposed as a fact by managing the cookie with a
|
||||
provider. It also drops support for Puppet 2.7, adds many features
|
||||
and fixes several bugs.
|
||||
|
||||
#### Backwards-incompatible Changes
|
||||
|
||||
- Removed the rabbitmq_erlang_cookie fact and replaced the logic to
|
||||
manage that cookie with a provider.
|
||||
- Dropped official support for Puppet 2.7 (EOL 9/30/2014
|
||||
https://groups.google.com/forum/#!topic/puppet-users/QLguMcLraLE )
|
||||
- Changed the default value of $rabbitmq::params::ldap_user_dn_pattern
|
||||
to not contain a variable
|
||||
- Removed deprecated parameters: $rabbitmq::cluster_disk_nodes,
|
||||
$rabbitmq::server::manage_service, and
|
||||
$rabbitmq::server::config_mirrored_queues
|
||||
|
||||
#### Features
|
||||
|
||||
- Add tcp_keepalive parameter to enable TCP keepalive
|
||||
- Use https to download rabbitmqadmin tool when $rabbitmq::ssl is true
|
||||
- Add key_content parameter for offline Debian package installations
|
||||
- Use 16 character apt key to avoid potential collisions
|
||||
- Add rabbitmq_policy type, including support for rabbitmq <3.2.0
|
||||
- Add rabbitmq::ensure_repo parameter
|
||||
- Add ability to change rabbitmq_user password
|
||||
- Allow disk as a valid cluster node type
|
||||
|
||||
#### Bugfixes
|
||||
|
||||
- Avoid attempting to install rabbitmqadmin via a proxy (since it is
|
||||
downloaded from localhost)
|
||||
- Optimize check for RHEL GPG key
|
||||
- Configure ssl_listener in stomp only if using ssl
|
||||
- Use rpm as default package provider for RedHat, bringing the module in
|
||||
line with the documented instructions to manage erlang separately and allowing
|
||||
the default version and source parameters to become meaningful
|
||||
- Configure cacertfile only if verify_none is not set
|
||||
- Use -q flag for rabbitmqctl commands to avoid parsing inconsistent
|
||||
debug output
|
||||
- Use the -m flag for rabbitmqplugins commands, again to avoid parsing
|
||||
inconsistent debug output
|
||||
- Strip backslashes from the rabbitmqctl output to avoid parsing issues
|
||||
- Fix limitation where version parameter was ignored
|
||||
- Add /etc/rabbitmq/rabbitmqadmin.conf to fix rabbitmqadmin port usage
|
||||
when ssl is on
|
||||
- Fix linter errors and warnings
|
||||
- Add, update, and fix tests
|
||||
- Update docs
|
||||
|
||||
## 2014-08-20 - Version 4.1.0
|
||||
|
||||
### Summary
|
||||
|
||||
This release adds several new features, fixes bugs, and improves tests and
|
||||
documentation.
|
||||
|
||||
#### Features
|
||||
- Autorequire the rabbitmq-server service in the rabbitmq_vhost type
|
||||
- Add credentials to rabbitmqadmin URL
|
||||
- Added $ssl_only parameter to rabbitmq, rabbitmq::params, and
|
||||
rabbitmq::config
|
||||
- Added property tags to rabbitmq_user provider
|
||||
|
||||
#### Bugfixes
|
||||
- Fix erroneous commas in rabbitmq::config
|
||||
- Use correct ensure value for the rabbitmq_stomp rabbitmq_plugin
|
||||
- Set HOME env variable to nil when leveraging rabbitmq to remove type error
|
||||
from Python script
|
||||
- Fix location for rabbitmq-plugins for RHEL
|
||||
- Remove validation for package_source to allow it to be set to false
|
||||
- Allow LDAP auth configuration without configuring stomp
|
||||
- Added missing $ssl_verify and $ssl_fail_if_no_peer_cert to rabbitmq::config
|
||||
|
||||
## 2014-05-16 - Version 4.0.0
|
||||
|
||||
### Summary
|
||||
|
||||
This release includes many new features and bug fixes. With the exception of
|
||||
erlang management this should be backwards compatible with 3.1.0.
|
||||
|
||||
#### Backwards-incompatible Changes
|
||||
- erlang_manage was removed. You will need to manage erlang separately. See
|
||||
the README for more information on how to configure this.
|
||||
|
||||
#### Features
|
||||
- Improved SSL support
|
||||
- Add LDAP support
|
||||
- Add ability to manage RabbitMQ repositories
|
||||
- Add ability to manage Erlang kernel configuration options
|
||||
- Improved handling of user tags
|
||||
- Use nanliu-staging module instead of hardcoded 'curl'
|
||||
- Switch to yum or zypper provider instead of rpm
|
||||
- Add ability to manage STOMP plugin installation.
|
||||
- Allow empty permission fields
|
||||
- Convert existing system tests to beaker acceptance tests.
|
||||
|
||||
#### Bugfixes
|
||||
- exchanges no longer recreated on each puppet run if non-default vhost is used
|
||||
- Allow port to be UNSET
|
||||
- Re-added rabbitmq::server class
|
||||
- Deprecated previously unused manage_service variable in favor of
|
||||
service_manage
|
||||
- Use correct key for rabbitmq apt::source
|
||||
- config_mirrored_queues variable removed
|
||||
- It previously did nothing, will now at least throw a warning if you try to
|
||||
use it
|
||||
- Remove unnecessary dependency on Class['rabbitmq::repo::rhel'] in
|
||||
rabbitmq::install
|
||||
|
||||
|
||||
## 2013-09-14 - Version 3.1.0
|
||||
|
||||
### Summary
|
||||
|
||||
This release focuses on a few small (but critical) bugfixes as well as extends
|
||||
the amount of custom RabbitMQ configuration you can do with the module.
|
||||
|
||||
#### Features
|
||||
- You can now change RabbitMQ 'Config Variables' via the parameter `config_variables`.
|
||||
- You can now change RabbitMQ 'Environment Variables' via the parameter `environment_variables`.
|
||||
- ArchLinux support added.
|
||||
|
||||
#### Fixes
|
||||
- Make use of the user/password parameters in rabbitmq_exchange{}
|
||||
- Correct the read/write parameter order on set_permissions/list_permissions as
|
||||
they were reversed.
|
||||
- Make the module pull down 3.1.5 by default.
|
||||
|
||||
## 2013-07-18 3.0.0
|
||||
|
||||
### Summary
|
||||
|
||||
This release heavily refactors the RabbitMQ and changes functionality in
|
||||
several key ways. Please pay attention to the new README.md file for
|
||||
details of how to interact with the class now. Puppet 3 and RHEL are
|
||||
now fully supported. The default version of RabbitMQ has changed to
|
||||
a 3.x release.
|
||||
|
||||
#### Bugfixes
|
||||
|
||||
- Improve travis testing options.
|
||||
- Stop reimporting the GPG key on every run on RHEL and Debian.
|
||||
- Fix documentation to make it clear you don't have to set provider => each time.
|
||||
- Reference the standard rabbitmq port in the documentation instead of a custom port.
|
||||
- Fixes to the README formatting.
|
||||
|
||||
#### Features
|
||||
- Refactor the module to fix RHEL support. All interaction with the module
|
||||
is now done through the main rabbitmq class.
|
||||
- Add support for mirrored queues (Only on Debian family distributions currently)
|
||||
- Add rabbitmq_exchange provider (using rabbitmqadmin)
|
||||
- Add new `rabbitmq` class parameters:
|
||||
- `manage_service`: Boolean to choose if Puppet should manage the service. (For pacemaker/HA setups)
|
||||
- Add SuSE support.
|
||||
|
||||
#### Incompatible Changes
|
||||
|
||||
- Rabbitmq::server has been removed and is now rabbitmq::config. You should
|
||||
not use this class directly, only via the main rabbitmq class.
|
||||
|
||||
## 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
|
||||
|
||||
## 2012-05-03 2.0.0
|
||||
- added support for new-style admin users
|
||||
- added support for rabbitmq 2.7.1
|
||||
|
||||
## 2011-06-14 Dan Bode <dan@Puppetlabs.com> 2.0.0rc1
|
||||
- Massive refactor:
|
||||
- added native types for user/vhost/user_permissions
|
||||
- added apt support for vendor packages
|
||||
- added smoke tests
|
||||
|
||||
## 2011-04-08 Jeff McCune <jeff@puppetlabs.com> 1.0.4
|
||||
- Update module for RabbitMQ 2.4.1 and rabbitmq-plugin-stomp package.
|
||||
|
||||
## 2011-03-24 1.0.3
|
||||
- Initial release to the forge. Reviewed by Cody. Whitespace is good.
|
||||
|
||||
## 2011-03-22 1.0.2
|
||||
- Whitespace only fix again... ack '\t' is my friend...
|
||||
|
||||
## 2011-03-22 1.0.1
|
||||
- Whitespace only fix.
|
||||
|
||||
## 2011-03-22 1.0.0
|
||||
- Initial Release. Manage the package, file and service.
|
|
@ -1,30 +0,0 @@
|
|||
source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
||||
|
||||
group :development, :unit_tests do
|
||||
gem 'rake', :require => false
|
||||
gem 'rspec-puppet', :require => false
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', :require => false
|
||||
gem 'simplecov', :require => false
|
||||
gem 'puppet_facts', :require => false
|
||||
gem 'json', :require => false
|
||||
end
|
||||
|
||||
group :system_tests do
|
||||
gem 'beaker-rspec', :require => false
|
||||
gem 'serverspec', :require => false
|
||||
end
|
||||
|
||||
if facterversion = ENV['FACTER_GEM_VERSION']
|
||||
gem 'facter', facterversion, :require => false
|
||||
else
|
||||
gem 'facter', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
|
@ -1,201 +0,0 @@
|
|||
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 2013 Puppet Labs
|
||||
|
||||
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.
|
|
@ -1,540 +0,0 @@
|
|||
#rabbitmq
|
||||
|
||||
####Table of Contents
|
||||
|
||||
1. [Overview](#overview)
|
||||
2. [Module Description - What the module does and why it is useful](#module-description)
|
||||
3. [Setup - The basics of getting started with rabbitmq](#setup)
|
||||
* [What rabbitmq affects](#what-rabbitmq-affects)
|
||||
* [Setup requirements](#setup-requirements)
|
||||
* [Beginning with rabbitmq](#beginning-with-rabbitmq)
|
||||
4. [Usage - Configuration options and additional functionality](#usage)
|
||||
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
|
||||
5. [Limitations - OS compatibility, etc.](#limitations)
|
||||
* [RedHat module dependencies](#redhat-module-dependecies)
|
||||
6. [Development - Guide for contributing to the module](#development)
|
||||
|
||||
##Overview
|
||||
|
||||
This module manages RabbitMQ (www.rabbitmq.com)
|
||||
|
||||
##Module Description
|
||||
The rabbitmq module sets up rabbitmq and has a number of providers to manage
|
||||
everything from vhosts to exchanges after setup.
|
||||
|
||||
This module has been tested against 2.7.1 and is known to not support
|
||||
all features against earlier versions.
|
||||
|
||||
##Setup
|
||||
|
||||
###What rabbitmq affects
|
||||
|
||||
* rabbitmq repository files.
|
||||
* rabbitmq package.
|
||||
* rabbitmq configuration file.
|
||||
* rabbitmq service.
|
||||
|
||||
###Beginning with rabbitmq
|
||||
|
||||
|
||||
```puppet
|
||||
include '::rabbitmq'
|
||||
```
|
||||
|
||||
##Usage
|
||||
|
||||
All options and configuration can be done through interacting with the parameters
|
||||
on the main rabbitmq class. These are documented below.
|
||||
|
||||
##rabbitmq class
|
||||
|
||||
To begin with the rabbitmq class controls the installation of rabbitmq. In here
|
||||
you can control many parameters relating to the package and service, such as
|
||||
disabling puppet support of the service:
|
||||
|
||||
```puppet
|
||||
class { '::rabbitmq':
|
||||
service_manage => false,
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
}
|
||||
```
|
||||
|
||||
Or such as offline installation from intranet or local mirrors:
|
||||
|
||||
```puppet
|
||||
class { '::rabbitmq':
|
||||
key_content => template('openstack/rabbit.pub.key'),
|
||||
package_gpg_key => '/tmp/rabbit.pub.key',
|
||||
}
|
||||
```
|
||||
|
||||
And this one will use external package key source for any (apt/rpm) package provider:
|
||||
|
||||
```puppet
|
||||
class { '::rabbitmq':
|
||||
package_gpg_key => 'http://www.some_site.some_domain/some_key.pub.key',
|
||||
}
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
To use RabbitMQ Environment Variables, use the parameters `environment_variables` e.g.:
|
||||
|
||||
```puppet
|
||||
class { 'rabbitmq':
|
||||
port => '5672',
|
||||
environment_variables => {
|
||||
'NODENAME' => 'node01',
|
||||
'SERVICENAME' => 'RabbitMQ'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Variables Configurable in rabbitmq.config
|
||||
To change RabbitMQ Config Variables in rabbitmq.config, use the parameters `config_variables` e.g.:
|
||||
|
||||
```puppet
|
||||
class { 'rabbitmq':
|
||||
port => '5672',
|
||||
config_variables => {
|
||||
'hipe_compile' => true,
|
||||
'frame_max' => 131072,
|
||||
'log_levels' => "[{connection, info}]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To change Erlang Kernel Config Variables in rabbitmq.config, use the parameters
|
||||
`config_kernel_variables` e.g.:
|
||||
|
||||
```puppet
|
||||
class { 'rabbitmq':
|
||||
port => '5672',
|
||||
config_kernel_variables => {
|
||||
'inet_dist_listen_min' => 9100,
|
||||
'inet_dist_listen_max' => 9105,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To change Management Plugin Config Variables in rabbitmq.config, use the parameters
|
||||
`config_rabbitmq_management_variables` e.g.:
|
||||
|
||||
```puppet
|
||||
class { 'rabbitmq':
|
||||
config_rabbitmq_management_variables => {
|
||||
'rates_mode' => 'basic',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Clustering
|
||||
To use RabbitMQ clustering facilities, use the rabbitmq parameters
|
||||
`config_cluster`, `cluster_nodes`, and `cluster_node_type`, e.g.:
|
||||
|
||||
```puppet
|
||||
class { 'rabbitmq':
|
||||
config_cluster => true,
|
||||
cluster_nodes => ['rabbit1', 'rabbit2'],
|
||||
cluster_node_type => 'ram',
|
||||
}
|
||||
```
|
||||
|
||||
##Reference
|
||||
|
||||
##Classes
|
||||
|
||||
* rabbitmq: Main class for installation and service management.
|
||||
* rabbitmq::config: Main class for rabbitmq configuration/management.
|
||||
* rabbitmq::install: Handles package installation.
|
||||
* rabbitmq::params: Different configuration data for different systems.
|
||||
* rabbitmq::service: Handles the rabbitmq service.
|
||||
* rabbitmq::repo::apt: Handles apt repo for Debian systems.
|
||||
* rabbitmq::repo::rhel: Handles rpm repo for Redhat systems.
|
||||
|
||||
###Parameters
|
||||
|
||||
####`admin_enable`
|
||||
|
||||
Boolean, if enabled sets up the management interface/plugin for RabbitMQ.
|
||||
|
||||
####`cluster_node_type`
|
||||
|
||||
Choose between disk and ram nodes.
|
||||
|
||||
####`cluster_nodes`
|
||||
|
||||
An array of nodes for clustering.
|
||||
|
||||
####`cluster_partition_handling`
|
||||
|
||||
Value to set for `cluster_partition_handling` RabbitMQ configuration variable.
|
||||
|
||||
####`config`
|
||||
|
||||
The file to use as the rabbitmq.config template.
|
||||
|
||||
####`config_cluster`
|
||||
|
||||
Boolean to enable or disable clustering support.
|
||||
|
||||
####`config_kernel_variables`
|
||||
|
||||
Hash of Erlang kernel configuration variables to set (see [Variables Configurable in rabbitmq.config](#variables-configurable-in-rabbitmq.config)).
|
||||
|
||||
####`config_mirrored_queues`
|
||||
|
||||
DEPRECATED
|
||||
|
||||
Configuring queue mirroring should be done by setting the according policy for
|
||||
the queue. You can read more about it
|
||||
[here](http://www.rabbitmq.com/ha.html#genesis)
|
||||
|
||||
####`config_path`
|
||||
|
||||
The path to write the RabbitMQ configuration file to.
|
||||
|
||||
####`config_stomp`
|
||||
|
||||
Boolean to enable or disable stomp.
|
||||
|
||||
####`config_variables`
|
||||
|
||||
To set config variables in rabbitmq.config
|
||||
|
||||
####`default_user`
|
||||
|
||||
Username to set for the `default_user` in rabbitmq.config.
|
||||
|
||||
####`default_pass`
|
||||
|
||||
Password to set for the `default_user` in rabbitmq.config.
|
||||
|
||||
####`delete_guest_user`
|
||||
|
||||
Boolean to decide if we should delete the default guest user.
|
||||
|
||||
####`env_config`
|
||||
|
||||
The template file to use for rabbitmq_env.config.
|
||||
|
||||
####`env_config_path`
|
||||
|
||||
The path to write the rabbitmq_env.config file to.
|
||||
|
||||
####`environment_variables`
|
||||
|
||||
RabbitMQ Environment Variables in rabbitmq_env.config
|
||||
|
||||
####`erlang_cookie`
|
||||
|
||||
The erlang cookie to use for clustering - must be the same between all nodes.
|
||||
This value has no default and must be set explicitly if using clustering.
|
||||
|
||||
###`key_content`
|
||||
|
||||
Uses content method for Debian OS family. Should be a template for apt::source
|
||||
class. Overrides `package_gpg_key` behavior, if enabled. Undefined by default.
|
||||
|
||||
####`ldap_auth`
|
||||
|
||||
Boolean, set to true to enable LDAP auth.
|
||||
|
||||
####`ldap_server`
|
||||
|
||||
LDAP server to use for auth.
|
||||
|
||||
####`ldap_user_dn_pattern`
|
||||
|
||||
User DN pattern for LDAP auth.
|
||||
|
||||
####`ldap_use_ssl`
|
||||
|
||||
Boolean, set to true to use SSL for the LDAP server.
|
||||
|
||||
####`ldap_port`
|
||||
|
||||
Numeric port for LDAP server.
|
||||
|
||||
####`ldap_log`
|
||||
|
||||
Boolean, set to true to log LDAP auth.
|
||||
|
||||
####`manage_repos`
|
||||
|
||||
Boolean, whether or not to manage package repositories.
|
||||
|
||||
####`management_port`
|
||||
|
||||
The port for the RabbitMQ management interface.
|
||||
|
||||
####`node_ip_address`
|
||||
|
||||
The value of NODE_IP_ADDRESS in rabbitmq_env.config
|
||||
|
||||
####`package_ensure`
|
||||
|
||||
Determines the ensure state of the package. Set to installed by default, but could
|
||||
be changed to latest.
|
||||
|
||||
####`package_gpg_key`
|
||||
|
||||
RPM package GPG key to import. Uses source method. Should be a URL for Debian/RedHat
|
||||
OS family, or a file name for RedHat OS family.
|
||||
Set to http://www.rabbitmq.com/rabbitmq-signing-key-public.asc by default.
|
||||
Note, that `key_content`, if specified, would override this parameter for Debian OS family.
|
||||
|
||||
####`package_name`
|
||||
|
||||
The name of the package to install.
|
||||
|
||||
####`package_provider`
|
||||
|
||||
What provider to use to install the package.
|
||||
|
||||
####`package_source`
|
||||
|
||||
Where should the package be installed from?
|
||||
|
||||
On Debian- and Arch-based systems using the default package provider,
|
||||
this parameter is ignored and the package is installed from the
|
||||
rabbitmq repository, if enabled with manage_repo => true, or from the
|
||||
system repository otherwise. If you want to use dpkg as the
|
||||
package_provider, you must specify a local package_source.
|
||||
|
||||
####`plugin_dir`
|
||||
|
||||
Location of RabbitMQ plugins.
|
||||
|
||||
####`port`
|
||||
|
||||
The RabbitMQ port.
|
||||
|
||||
####`service_ensure`
|
||||
|
||||
The state of the service.
|
||||
|
||||
####`service_manage`
|
||||
|
||||
Determines if the service is managed.
|
||||
|
||||
####`service_name`
|
||||
|
||||
The name of the service to manage.
|
||||
|
||||
####`ssl`
|
||||
|
||||
Configures the service for using SSL.
|
||||
|
||||
####`ssl_only`
|
||||
|
||||
Configures the service to only use SSL. No cleartext TCP listeners will be created.
|
||||
Requires that ssl => true also.
|
||||
|
||||
####`ssl_cacert`
|
||||
|
||||
CA cert path to use for SSL.
|
||||
|
||||
####`ssl_cert`
|
||||
|
||||
Cert to use for SSL.
|
||||
|
||||
####`ssl_key`
|
||||
|
||||
Key to use for SSL.
|
||||
|
||||
####`ssl_management_port`
|
||||
|
||||
SSL management port.
|
||||
|
||||
####`ssl_stomp_port`
|
||||
|
||||
SSL stomp port.
|
||||
|
||||
####`ssl_verify`
|
||||
|
||||
rabbitmq.config SSL verify setting.
|
||||
|
||||
####`ssl_fail_if_no_peer_cert`
|
||||
|
||||
rabbitmq.config `fail_if_no_peer_cert` setting.
|
||||
|
||||
####`stomp_port`
|
||||
|
||||
The port to use for Stomp.
|
||||
|
||||
####`stomp_ensure`
|
||||
|
||||
Boolean to install the stomp plugin.
|
||||
|
||||
####`tcp_keepalive`
|
||||
|
||||
Boolean to enable TCP connection keepalive for RabbitMQ service.
|
||||
|
||||
####`version`
|
||||
|
||||
Sets the version to install.
|
||||
|
||||
On Debian- and Arch-based operating systems, the version parameter is
|
||||
ignored and the latest version is installed from the rabbitmq
|
||||
repository, if enabled with manage_repo => true, or from the system
|
||||
repository otherwise.
|
||||
|
||||
####`wipe_db_on_cookie_change`
|
||||
|
||||
Boolean to determine if we should DESTROY AND DELETE the RabbitMQ database.
|
||||
|
||||
##Native Types
|
||||
|
||||
### rabbitmq\_user
|
||||
|
||||
query all current users: `$ puppet resource rabbitmq_user`
|
||||
|
||||
```
|
||||
rabbitmq_user { 'dan':
|
||||
admin => true,
|
||||
password => 'bar',
|
||||
}
|
||||
```
|
||||
Optional parameter tags will set further rabbitmq tags like monitoring, policymaker, etc.
|
||||
To set the administrator tag use admin-flag.
|
||||
```puppet
|
||||
rabbitmq_user { 'dan':
|
||||
admin => true,
|
||||
password => 'bar',
|
||||
tags => ['monitoring', 'tag1'],
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### rabbitmq\_vhost
|
||||
|
||||
query all current vhosts: `$ puppet resource rabbitmq_vhost`
|
||||
|
||||
```puppet
|
||||
rabbitmq_vhost { 'myhost':
|
||||
ensure => present,
|
||||
}
|
||||
```
|
||||
|
||||
### rabbitmq\_exchange
|
||||
|
||||
```puppet
|
||||
rabbitmq_exchange { 'myexchange@myhost':
|
||||
user => 'dan',
|
||||
password => 'bar',
|
||||
type => 'topic',
|
||||
ensure => present,
|
||||
}
|
||||
```
|
||||
|
||||
### rabbitmq\_user\_permissions
|
||||
|
||||
```puppet
|
||||
rabbitmq_user_permissions { 'dan@myhost':
|
||||
configure_permission => '.*',
|
||||
read_permission => '.*',
|
||||
write_permission => '.*',
|
||||
}
|
||||
```
|
||||
|
||||
### rabbitmq\_policy
|
||||
|
||||
```puppet
|
||||
rabbitmq_policy { 'ha-all@myhost':
|
||||
pattern => '.*',
|
||||
priority => 0,
|
||||
applyto => 'all',
|
||||
definition => {
|
||||
'ha-mode' => 'all',
|
||||
'ha-sync-mode' => 'automatic',
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### rabbitmq\_plugin
|
||||
|
||||
query all currently enabled plugins `$ puppet resource rabbitmq_plugin`
|
||||
|
||||
```puppet
|
||||
rabbitmq_plugin {'rabbitmq_stomp':
|
||||
ensure => present,
|
||||
}
|
||||
```
|
||||
|
||||
### rabbitmq\_erlang\_cookie
|
||||
|
||||
This is essentially a private type used by the rabbitmq::config class
|
||||
to manage the erlang cookie. It replaces the rabbitmq_erlang_cookie fact
|
||||
from earlier versions of this module. It manages the content of the cookie
|
||||
usually located at /var/lib/rabbitmq/.erlang.cookie, which includes
|
||||
stopping the rabbitmq service and wiping out the database at
|
||||
/var/lib/rabbitmq/mnesia if the user agrees to it. We don't recommend using
|
||||
this type directly.
|
||||
|
||||
##Limitations
|
||||
|
||||
This module has been built on and tested against Puppet 3.x.
|
||||
|
||||
The module has been tested on:
|
||||
|
||||
* RedHat Enterprise Linux 5/6
|
||||
* Debian 6/7
|
||||
* CentOS 5/6
|
||||
* Ubuntu 12.04/14.04
|
||||
|
||||
Testing on other platforms has been light and cannot be guaranteed.
|
||||
|
||||
### Module dependencies
|
||||
|
||||
If running CentOS/RHEL, and using the yum provider, ensure the epel repo is present.
|
||||
|
||||
To have a suitable erlang version installed on RedHat and Debian systems,
|
||||
you have to install another puppet module from http://forge.puppetlabs.com/garethr/erlang with:
|
||||
|
||||
puppet module install garethr-erlang
|
||||
|
||||
This module handles the packages for erlang.
|
||||
To use the module, add the following snippet to your site.pp or an appropriate profile class:
|
||||
|
||||
For RedHat systems:
|
||||
|
||||
include 'erlang'
|
||||
class { 'erlang': epel_enable => true}
|
||||
|
||||
For Debian systems:
|
||||
|
||||
include 'erlang'
|
||||
package { 'erlang-base':
|
||||
ensure => 'latest',
|
||||
}
|
||||
|
||||
### Downgrade Issues
|
||||
|
||||
Be advised that there were configuration file syntax and other changes made between RabbitMQ
|
||||
versions 2 and 3. In order to downgrade from 3 to 2 (not that this is a terribly good idea)
|
||||
you will need to manually remove all RabbitMQ configuration files (``/etc/rabbitmq``) and
|
||||
the mnesia directory (usually ``/var/lib/rabbitmq/mnesia``). The latter action will delete
|
||||
any and all messages stored to disk.
|
||||
|
||||
Failure to do this will result in RabbitMQ failing to start with a cryptic error message about
|
||||
"init terminating in do_boot", containing "rabbit_upgrade,maybe_upgrade_mnesia".
|
||||
|
||||
##Development
|
||||
|
||||
Puppet Labs modules on the Puppet Forge are open projects, and community
|
||||
contributions are essential for keeping them great. We can’t access the
|
||||
huge number of platforms and myriad of hardware, software, and deployment
|
||||
configurations that Puppet is intended to serve.
|
||||
|
||||
We want to keep it as easy as possible to contribute changes so that our
|
||||
modules work in your environment. There are a few guidelines that we need
|
||||
contributors to follow so that we can have a chance of keeping on top of things.
|
||||
|
||||
You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing)
|
||||
|
||||
### Authors
|
||||
* Jeff McCune <jeff@puppetlabs.com>
|
||||
* Dan Bode <dan@puppetlabs.com>
|
||||
* RPM/RHEL packages by Vincent Janelle <randomfrequency@gmail.com>
|
||||
* Puppetlabs Module Team
|
|
@ -1,11 +0,0 @@
|
|||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
|
||||
PuppetLint.configuration.fail_on_warnings
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
||||
PuppetLint.configuration.send('disable_class_parameter_defaults')
|
||||
PuppetLint.configuration.send('disable_documentation')
|
||||
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
|
||||
PuppetLint.configuration.fail_on_warnings = true
|
||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
|
@ -1,10 +0,0 @@
|
|||
provider TODO -
|
||||
- password should be a property and not a param
|
||||
- what if we tried to log in as that user?
|
||||
- can permissions from list_user_permissions contain whitespace?
|
||||
- what about defaultfor :true?
|
||||
- prefetching for performance
|
||||
- rabbit plugin should require rabbitmq class
|
||||
- rabbitmq class should be renamed server??
|
||||
- service name should default to -server
|
||||
- cannot find stomp package
|
|
@ -1,22 +0,0 @@
|
|||
Files
|
||||
=====
|
||||
|
||||
Puppet comes with both a client and server for copying files around. The file
|
||||
serving function is provided as part of the central Puppet daemon,
|
||||
puppetmasterd, and the client function is used through the source attribute of
|
||||
file objects. Learn more at
|
||||
http://projects.puppetlabs.com/projects/puppet/wiki/File_Serving_Configuration
|
||||
|
||||
You can use managed files like this:
|
||||
|
||||
class myclass {
|
||||
package { mypackage: ensure => latest }
|
||||
service { myservice: ensure => running }
|
||||
file { "/etc/myfile":
|
||||
source => "puppet://$servername/modules/mymodule/myfile"
|
||||
}
|
||||
}
|
||||
|
||||
The files are searched for in:
|
||||
|
||||
$modulepath/mymodule/files/myfile
|
Binary file not shown.
Binary file not shown.
|
@ -1,16 +0,0 @@
|
|||
# Fact: rabbitmq_erlang_cookie
|
||||
#
|
||||
# Purpose: To determine the current erlang cookie value.
|
||||
#
|
||||
# Resolution: Returns the cookie.
|
||||
Facter.add(:rabbitmq_erlang_cookie) do
|
||||
confine :osfamily => %w[Debian RedHat Suse]
|
||||
|
||||
setcode do
|
||||
if File.exists?('/var/lib/rabbitmq/.erlang.cookie')
|
||||
File.read('/var/lib/rabbitmq/.erlang.cookie')
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'set'
|
||||
Puppet::Type.type(:rabbitmq_erlang_cookie).provide(:ruby) do
|
||||
|
||||
defaultfor :feature => :posix
|
||||
has_command(:puppet, 'puppet') do
|
||||
environment :PATH => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'
|
||||
end
|
||||
|
||||
def exists?
|
||||
# Hack to prevent the create method from being called.
|
||||
# We never need to create or destroy this resource, only change its value
|
||||
true
|
||||
end
|
||||
|
||||
def content=(value)
|
||||
if resource[:force] == :true # Danger!
|
||||
puppet('resource', 'service', resource[:service_name], 'ensure=stopped')
|
||||
FileUtils.rm_rf('/var/lib/rabbitmq/mnesia')
|
||||
File.open(resource[:path], 'w') do |cookie|
|
||||
cookie.chmod(0400)
|
||||
cookie.write(value)
|
||||
end
|
||||
FileUtils.chown('rabbitmq', 'rabbitmq', resource[:path])
|
||||
else
|
||||
fail("The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this to happen automatically.")
|
||||
end
|
||||
end
|
||||
|
||||
def content
|
||||
if File.exists?(resource[:path])
|
||||
File.read(resource[:path])
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,125 +0,0 @@
|
|||
require 'puppet'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_exchange).provide(:rabbitmqadmin, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
if Puppet::PUPPETVERSION.to_f < 3
|
||||
commands :rabbitmqctl => 'rabbitmqctl'
|
||||
commands :rabbitmqadmin => '/usr/local/bin/rabbitmqadmin'
|
||||
else
|
||||
has_command(:rabbitmqctl, 'rabbitmqctl') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
has_command(:rabbitmqadmin, '/usr/local/bin/rabbitmqadmin') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
end
|
||||
defaultfor :feature => :posix
|
||||
|
||||
def retry_rabbitmqctl(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqctl(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def retry_rabbitmqadmin(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqadmin(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqadmin(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqadmin(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def should_vhost
|
||||
if @should_vhost
|
||||
@should_vhost
|
||||
else
|
||||
@should_vhost = resource[:name].split('@')[1]
|
||||
end
|
||||
end
|
||||
|
||||
def self.all_vhosts
|
||||
vhosts = []
|
||||
parse_command(
|
||||
retry_rabbitmqctl('list_vhosts')
|
||||
).collect do |vhost|
|
||||
vhosts.push(vhost)
|
||||
end
|
||||
vhosts
|
||||
end
|
||||
|
||||
def self.all_exchanges(vhost)
|
||||
exchanges = []
|
||||
parse_command(
|
||||
retry_rabbitmqctl('list_exchanges', '-p', vhost, 'name', 'type')
|
||||
)
|
||||
end
|
||||
|
||||
def self.parse_command(cmd_output)
|
||||
# first line is:
|
||||
# Listing exchanges/vhosts ...
|
||||
# while the last line is
|
||||
# ...done.
|
||||
#
|
||||
cmd_output.split(/\n/)[1..-2]
|
||||
end
|
||||
|
||||
def self.instances
|
||||
resources = []
|
||||
all_vhosts.each do |vhost|
|
||||
all_exchanges(vhost).collect do |line|
|
||||
name, type = line.split()
|
||||
if type.nil?
|
||||
# if name is empty, it will wrongly get the type's value.
|
||||
# This way type will get the correct value
|
||||
type = name
|
||||
name = ''
|
||||
end
|
||||
exchange = {
|
||||
:type => type,
|
||||
:ensure => :present,
|
||||
:name => "%s@%s" % [name, vhost],
|
||||
}
|
||||
resources << new(exchange) if exchange[:type]
|
||||
end
|
||||
end
|
||||
resources
|
||||
end
|
||||
|
||||
def self.prefetch(resources)
|
||||
packages = instances
|
||||
resources.keys.each do |name|
|
||||
if provider = packages.find{ |pkg| pkg.name == name }
|
||||
resources[name].provider = provider
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def exists?
|
||||
@property_hash[:ensure] == :present
|
||||
end
|
||||
|
||||
def create
|
||||
vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : ''
|
||||
name = resource[:name].split('@')[0]
|
||||
retry_rabbitmqadmin('declare', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", "type=#{resource[:type]}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
|
||||
@property_hash[:ensure] = :present
|
||||
end
|
||||
|
||||
def destroy
|
||||
vhost_opt = should_vhost ? "--vhost=#{should_vhost}" : ''
|
||||
name = resource[:name].split('@')[0]
|
||||
retry_rabbitmqadmin('delete', 'exchange', vhost_opt, "--user=#{resource[:user]}", "--password=#{resource[:password]}", "name=#{name}", '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
|
||||
@property_hash[:ensure] = :absent
|
||||
end
|
||||
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
if Puppet::PUPPETVERSION.to_f < 3
|
||||
if Facter.value(:osfamily) == 'RedHat'
|
||||
commands :rabbitmqplugins => '/usr/lib/rabbitmq/bin/rabbitmq-plugins'
|
||||
else
|
||||
commands :rabbitmqplugins => 'rabbitmq-plugins'
|
||||
end
|
||||
else
|
||||
if Facter.value(:osfamily) == 'RedHat'
|
||||
has_command(:rabbitmqplugins, '/usr/lib/rabbitmq/bin/rabbitmq-plugins') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
else
|
||||
has_command(:rabbitmqplugins, 'rabbitmq-plugins') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defaultfor :feature => :posix
|
||||
|
||||
def retry_rabbitmqplugins(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqplugins(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqplugins(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqplugins(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.instances
|
||||
retry_rabbitmqplugins('list', '-E', '-m').split(/\n/).map do |line|
|
||||
if line =~ /^(\S+)$/
|
||||
new(:name => $1)
|
||||
else
|
||||
raise Puppet::Error, "Cannot parse invalid plugins line: #{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
retry_rabbitmqplugins('enable', resource[:name])
|
||||
end
|
||||
|
||||
def destroy
|
||||
retry_rabbitmqplugins('disable', resource[:name])
|
||||
end
|
||||
|
||||
def exists?
|
||||
retry_rabbitmqplugins('list', '-E', '-m').split(/\n/).detect do |line|
|
||||
line.match(/^#{resource[:name]}$/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,137 +0,0 @@
|
|||
require 'json'
|
||||
require 'puppet/util/package'
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_policy).provide(:rabbitmqctl, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
defaultfor :feature => :posix
|
||||
|
||||
def retry_rabbitmqctl(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqctl(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
# cache policies
|
||||
def self.policies(name, vhost)
|
||||
@policies = {} unless @policies
|
||||
unless @policies[vhost]
|
||||
@policies[vhost] = {}
|
||||
retry_rabbitmqctl('list_policies', '-q', '-p', vhost).split(/\n/).each do |line|
|
||||
# rabbitmq<3.2 does not support the applyto field
|
||||
# 1 2 3? 4 5 6
|
||||
# / ha-all all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0
|
||||
if line =~ /^(\S+)\s+(\S+)\s+(all|exchanges|queues)?\s*(\S+)\s+(\S+)\s+(\d+)$/
|
||||
applyto = $3 || 'all'
|
||||
@policies[vhost][$2] = {
|
||||
:applyto => applyto,
|
||||
:pattern => $4,
|
||||
:definition => JSON.parse($5),
|
||||
:priority => $6}
|
||||
else
|
||||
raise Puppet::Error, "cannot parse line from list_policies:#{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@policies[vhost][name]
|
||||
end
|
||||
|
||||
def policies(name, vhost)
|
||||
self.class.policies(vhost, name)
|
||||
end
|
||||
|
||||
def should_policy
|
||||
if @should_policy
|
||||
@should_policy
|
||||
else
|
||||
@should_policy = resource[:name].rpartition('@').first
|
||||
end
|
||||
end
|
||||
|
||||
def should_vhost
|
||||
if @should_vhost
|
||||
@should_vhost
|
||||
else
|
||||
@should_vhost = resource[:name].rpartition('@').last
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
set_policy
|
||||
end
|
||||
|
||||
def destroy
|
||||
retry_rabbitmqctl('clear_policy', '-p', should_vhost, should_policy)
|
||||
end
|
||||
|
||||
def exists?
|
||||
policies(should_vhost, should_policy)
|
||||
end
|
||||
|
||||
def pattern
|
||||
policies(should_vhost, should_policy)[:pattern]
|
||||
end
|
||||
|
||||
def pattern=(pattern)
|
||||
set_policy
|
||||
end
|
||||
|
||||
def applyto
|
||||
policies(should_vhost, should_policy)[:applyto]
|
||||
end
|
||||
|
||||
def applyto=(applyto)
|
||||
set_policy
|
||||
end
|
||||
|
||||
def definition
|
||||
policies(should_vhost, should_policy)[:definition]
|
||||
end
|
||||
|
||||
def definition=(definition)
|
||||
set_policy
|
||||
end
|
||||
|
||||
def priority
|
||||
policies(should_vhost, should_policy)[:priority]
|
||||
end
|
||||
|
||||
def priority=(priority)
|
||||
set_policy
|
||||
end
|
||||
|
||||
def set_policy
|
||||
unless @set_policy
|
||||
@set_policy = true
|
||||
resource[:applyto] ||= applyto
|
||||
resource[:definition] ||= definition
|
||||
resource[:pattern] ||= pattern
|
||||
resource[:priority] ||= priority
|
||||
# rabbitmq>=3.2.0
|
||||
if Puppet::Util::Package.versioncmp(self.class.rabbitmq_version, '3.2.0') >= 0
|
||||
retry_rabbitmqctl('set_policy',
|
||||
'-p', should_vhost,
|
||||
'--priority', resource[:priority],
|
||||
'--apply-to', resource[:applyto].to_s,
|
||||
should_policy,
|
||||
resource[:pattern],
|
||||
resource[:definition].to_json
|
||||
)
|
||||
else
|
||||
retry_rabbitmqctl('set_policy',
|
||||
'-p', should_vhost,
|
||||
should_policy,
|
||||
resource[:pattern],
|
||||
resource[:definition].to_json,
|
||||
resource[:priority]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,129 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'set'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_user).provide(:rabbitmqctl, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
if Puppet::PUPPETVERSION.to_f < 3
|
||||
commands :rabbitmqctl => 'rabbitmqctl'
|
||||
else
|
||||
has_command(:rabbitmqctl, 'rabbitmqctl') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
end
|
||||
|
||||
defaultfor :feature => :posix
|
||||
|
||||
def retry_rabbitmqctl(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqctl(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.instances
|
||||
retry_rabbitmqctl('-q', 'list_users').split(/\n/).collect do |line|
|
||||
if line =~ /^(\S+)(\s+\[.*?\]|)$/
|
||||
new(:name => $1)
|
||||
else
|
||||
raise Puppet::Error, "Cannot parse invalid user line: #{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
retry_rabbitmqctl('add_user', resource[:name], resource[:password])
|
||||
if resource[:admin] == :true
|
||||
make_user_admin()
|
||||
end
|
||||
if !resource[:tags].nil?
|
||||
set_user_tags(resource[:tags])
|
||||
end
|
||||
end
|
||||
|
||||
def change_password
|
||||
retry_rabbitmqctl('change_password', resource[:name], resource[:password])
|
||||
end
|
||||
|
||||
def password
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
def check_password
|
||||
response = retry_rabbitmqctl('eval', 'rabbit_access_control:check_user_pass_login(list_to_binary("' + resource[:name] + '"), list_to_binary("' + resource[:password] + '")).')
|
||||
if response.include? 'refused'
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
retry_rabbitmqctl('delete_user', resource[:name])
|
||||
end
|
||||
|
||||
def exists?
|
||||
retry_rabbitmqctl('-q', 'list_users').split(/\n/).detect do |line|
|
||||
line.match(/^#{Regexp.escape(resource[:name])}(\s+(\[.*?\]|\S+)|)$/)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def tags
|
||||
get_user_tags.entries.sort
|
||||
end
|
||||
|
||||
|
||||
def tags=(tags)
|
||||
if ! tags.nil?
|
||||
set_user_tags(tags)
|
||||
end
|
||||
end
|
||||
|
||||
def admin
|
||||
if usertags = get_user_tags
|
||||
(:true if usertags.include?('administrator')) || :false
|
||||
else
|
||||
raise Puppet::Error, "Could not match line '#{resource[:name]} (true|false)' from list_users (perhaps you are running on an older version of rabbitmq that does not support admin users?)"
|
||||
end
|
||||
end
|
||||
|
||||
def admin=(state)
|
||||
if state == :true
|
||||
make_user_admin()
|
||||
else
|
||||
usertags = get_user_tags
|
||||
usertags.delete('administrator')
|
||||
retry_rabbitmqctl('set_user_tags', resource[:name], usertags.entries.sort)
|
||||
end
|
||||
end
|
||||
|
||||
def set_user_tags(tags)
|
||||
is_admin = get_user_tags().member?("administrator") \
|
||||
|| resource[:admin] == :true
|
||||
usertags = Set.new(tags)
|
||||
if is_admin
|
||||
usertags.add("administrator")
|
||||
end
|
||||
retry_rabbitmqctl('set_user_tags', resource[:name], usertags.entries.sort)
|
||||
end
|
||||
|
||||
def make_user_admin
|
||||
usertags = get_user_tags
|
||||
usertags.add('administrator')
|
||||
retry_rabbitmqctl('set_user_tags', resource[:name], usertags.entries.sort)
|
||||
end
|
||||
|
||||
private
|
||||
def get_user_tags
|
||||
match = retry_rabbitmqctl('-q', 'list_users').split(/\n/).collect do |line|
|
||||
line.match(/^#{Regexp.escape(resource[:name])}\s+\[(.*?)\]/)
|
||||
end.compact.first
|
||||
Set.new(match[1].split(/, /)) if match
|
||||
end
|
||||
end
|
|
@ -1,124 +0,0 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_user_permissions).provide(:rabbitmqctl, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
if Puppet::PUPPETVERSION.to_f < 3
|
||||
commands :rabbitmqctl => 'rabbitmqctl'
|
||||
else
|
||||
has_command(:rabbitmqctl, 'rabbitmqctl') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
end
|
||||
|
||||
defaultfor :feature=> :posix
|
||||
|
||||
def retry_rabbitmqctl(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqctl(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
# cache users permissions
|
||||
def self.users(name, vhost)
|
||||
@users = {} unless @users
|
||||
unless @users[name]
|
||||
@users[name] = {}
|
||||
retry_rabbitmqctl('-q', 'list_user_permissions', name).split(/\n/).each do |line|
|
||||
line = self::strip_backslashes(line)
|
||||
if line =~ /^(\S+)\s+(\S*)\s+(\S*)\s+(\S*)$/
|
||||
@users[name][$1] =
|
||||
{:configure => $2, :read => $4, :write => $3}
|
||||
else
|
||||
raise Puppet::Error, "cannot parse line from list_user_permissions:#{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@users[name][vhost]
|
||||
end
|
||||
|
||||
def users(name, vhost)
|
||||
self.class.users(name, vhost)
|
||||
end
|
||||
|
||||
def should_user
|
||||
if @should_user
|
||||
@should_user
|
||||
else
|
||||
@should_user = resource[:name].split('@')[0]
|
||||
end
|
||||
end
|
||||
|
||||
def should_vhost
|
||||
if @should_vhost
|
||||
@should_vhost
|
||||
else
|
||||
@should_vhost = resource[:name].split('@')[1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
resource[:configure_permission] ||= "''"
|
||||
resource[:read_permission] ||= "''"
|
||||
resource[:write_permission] ||= "''"
|
||||
retry_rabbitmqctl('set_permissions', '-p', should_vhost, should_user, resource[:configure_permission], resource[:write_permission], resource[:read_permission])
|
||||
end
|
||||
|
||||
def destroy
|
||||
retry_rabbitmqctl('clear_permissions', '-p', should_vhost, should_user)
|
||||
end
|
||||
|
||||
# I am implementing prefetching in exists b/c I need to be sure
|
||||
# that the rabbitmq package is installed before I make this call.
|
||||
def exists?
|
||||
users(should_user, should_vhost)
|
||||
end
|
||||
|
||||
def configure_permission
|
||||
users(should_user, should_vhost)[:configure]
|
||||
end
|
||||
|
||||
def configure_permission=(perm)
|
||||
set_permissions
|
||||
end
|
||||
|
||||
def read_permission
|
||||
users(should_user, should_vhost)[:read]
|
||||
end
|
||||
|
||||
def read_permission=(perm)
|
||||
set_permissions
|
||||
end
|
||||
|
||||
def write_permission
|
||||
users(should_user, should_vhost)[:write]
|
||||
end
|
||||
|
||||
def write_permission=(perm)
|
||||
set_permissions
|
||||
end
|
||||
|
||||
# implement memoization so that we only call set_permissions once
|
||||
def set_permissions
|
||||
unless @permissions_set
|
||||
@permissions_set = true
|
||||
resource[:configure_permission] ||= configure_permission
|
||||
resource[:read_permission] ||= read_permission
|
||||
resource[:write_permission] ||= write_permission
|
||||
rabbitmqctl('set_permissions', '-p', should_vhost, should_user,
|
||||
resource[:configure_permission], resource[:write_permission],
|
||||
resource[:read_permission]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def self.strip_backslashes(string)
|
||||
# See: https://github.com/rabbitmq/rabbitmq-server/blob/v1_7/docs/rabbitmqctl.1.pod#output-escaping
|
||||
string.gsub(/\\\\/, '\\')
|
||||
end
|
||||
|
||||
end
|
|
@ -1,48 +0,0 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rabbitmqctl'))
|
||||
Puppet::Type.type(:rabbitmq_vhost).provide(:rabbitmqctl, :parent => Puppet::Provider::Rabbitmqctl) do
|
||||
|
||||
if Puppet::PUPPETVERSION.to_f < 3
|
||||
commands :rabbitmqctl => 'rabbitmqctl'
|
||||
else
|
||||
has_command(:rabbitmqctl, 'rabbitmqctl') do
|
||||
environment :HOME => "/tmp"
|
||||
end
|
||||
end
|
||||
|
||||
def retry_rabbitmqctl(*args)
|
||||
self.class.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.retry_rabbitmqctl(*args)
|
||||
self.run_with_retries do
|
||||
rabbitmqctl(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def self.instances
|
||||
retry_rabbitmqctl('-q', 'list_vhosts').split(/\n/).map do |line|
|
||||
if line =~ /^(\S+)$/
|
||||
new(:name => $1)
|
||||
else
|
||||
raise Puppet::Error, "Cannot parse invalid user line: #{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
retry_rabbitmqctl('add_vhost', resource[:name])
|
||||
end
|
||||
|
||||
def destroy
|
||||
retry_rabbitmqctl('delete_vhost', resource[:name])
|
||||
end
|
||||
|
||||
def exists?
|
||||
out = retry_rabbitmqctl('-q', 'list_vhosts').split(/\n/).detect do |line|
|
||||
line.match(/^#{Regexp.escape(resource[:name])}$/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
class Puppet::Provider::Rabbitmqctl < Puppet::Provider
|
||||
initvars
|
||||
commands :rabbitmqctl => 'rabbitmqctl'
|
||||
|
||||
def self.rabbitmq_version
|
||||
output = rabbitmqctl('-q', 'status')
|
||||
version = output.match(/\{rabbit,"RabbitMQ","([\d\.]+)"\}/)
|
||||
version[1] if version
|
||||
end
|
||||
|
||||
# Retry the given code block 'count' retries or until the
|
||||
# command suceeeds. Use 'step' delay between retries.
|
||||
# Limit each query time by 'timeout'.
|
||||
# For example:
|
||||
# users = self.class.run_with_retries { rabbitmqctl 'list_users' }
|
||||
def self.run_with_retries(count=30, step=6, timeout=10)
|
||||
count.times do |n|
|
||||
begin
|
||||
output = Timeout::timeout(timeout) do
|
||||
yield
|
||||
end
|
||||
rescue Puppet::ExecutionFailure, Timeout => e
|
||||
Puppet.debug "Fail: #{e.to_s} Retry: #{n + 1}"
|
||||
sleep step
|
||||
else
|
||||
Puppet.debug 'Command succeeded'
|
||||
return output
|
||||
end
|
||||
end
|
||||
raise Puppet::Error, "Command is still failing after #{count * step} seconds expired!"
|
||||
end
|
||||
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_erlang_cookie) do
|
||||
desc 'Type to manage the rabbitmq erlang cookie securely'
|
||||
|
||||
newparam(:path, :namevar => true)
|
||||
|
||||
newproperty(:content) do
|
||||
desc 'Content of cookie'
|
||||
newvalues(/^\S+$/)
|
||||
def change_to_s(current, desired)
|
||||
"The rabbitmq erlang cookie was changed"
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:force) do
|
||||
defaultto(:false)
|
||||
newvalues(:true, :false)
|
||||
end
|
||||
|
||||
newparam(:service_name) do
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_exchange) do
|
||||
desc 'Native type for managing rabbitmq exchanges'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Name of exchange'
|
||||
newvalues(/^\S*@\S+$/)
|
||||
end
|
||||
|
||||
newparam(:type) do
|
||||
desc 'Exchange type to be set *on creation*'
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
|
||||
newparam(:user) do
|
||||
desc 'The user to use to connect to rabbitmq'
|
||||
defaultto('guest')
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
|
||||
newparam(:password) do
|
||||
desc 'The password to use to connect to rabbitmq'
|
||||
defaultto('guest')
|
||||
newvalues(/\S+/)
|
||||
end
|
||||
|
||||
validate do
|
||||
if self[:ensure] == :present and self[:type].nil?
|
||||
raise ArgumentError, "must set type when creating exchange for #{self[:name]} whose type is #{self[:type]}"
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_vhost) do
|
||||
[self[:name].split('@')[1]]
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_user) do
|
||||
[self[:user]]
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_user_permissions) do
|
||||
["#{self[:user]}@#{self[:name].split('@')[1]}"]
|
||||
end
|
||||
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_plugin) do
|
||||
desc 'manages rabbitmq plugins'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
'name of the plugin to enable'
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,76 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_policy) do
|
||||
desc 'Type for managing rabbitmq policies'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:service) { 'rabbitmq-server' }
|
||||
|
||||
validate do
|
||||
fail('pattern parameter is required.') if self[:ensure] == :present and self[:pattern].nil?
|
||||
fail('definition parameter is required.') if self[:ensure] == :present and self[:definition].nil?
|
||||
end
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'combination of policy@vhost to create policy for'
|
||||
newvalues(/^\S+@\S+$/)
|
||||
end
|
||||
|
||||
newproperty(:pattern) do
|
||||
desc 'policy pattern'
|
||||
validate do |value|
|
||||
resource.validate_pattern(value)
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:applyto) do
|
||||
desc 'policy apply to'
|
||||
newvalue(:all)
|
||||
newvalue(:exchanges)
|
||||
newvalue(:queues)
|
||||
defaultto :all
|
||||
end
|
||||
|
||||
newproperty(:definition) do
|
||||
desc 'policy definition'
|
||||
validate do |value|
|
||||
resource.validate_definition(value)
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:priority) do
|
||||
desc 'policy priority'
|
||||
newvalues(/^\d+$/)
|
||||
defaultto 0
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_vhost) do
|
||||
[self[:name].split('@')[1]]
|
||||
end
|
||||
|
||||
def validate_pattern(value)
|
||||
begin
|
||||
Regexp.new(value)
|
||||
rescue RegexpError
|
||||
raise ArgumentError, "Invalid regexp #{value}"
|
||||
end
|
||||
end
|
||||
|
||||
def validate_definition(definition)
|
||||
unless [Hash].include?(definition.class)
|
||||
raise ArgumentError, "Invalid definition"
|
||||
end
|
||||
definition.each do |k,v|
|
||||
unless [String].include?(v.class)
|
||||
raise ArgumentError, "Invalid definition"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_user) do
|
||||
desc 'Native type for managing rabbitmq users'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:service) { 'rabbitmq-server' }
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Name of user'
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
|
||||
newproperty(:password) do
|
||||
desc 'User password to be set *on creation* and validated each run'
|
||||
def insync?(is)
|
||||
provider.check_password
|
||||
end
|
||||
def set(value)
|
||||
provider.change_password
|
||||
end
|
||||
def change_to_s(current, desired)
|
||||
"password has been changed"
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:admin) do
|
||||
desc 'rather or not user should be an admin'
|
||||
newvalues(/true|false/)
|
||||
munge do |value|
|
||||
# converting to_s incase its a boolean
|
||||
value.to_s.to_sym
|
||||
end
|
||||
defaultto :false
|
||||
end
|
||||
|
||||
newproperty(:tags, :array_matching => :all) do
|
||||
desc 'additional tags for the user'
|
||||
end
|
||||
|
||||
validate do
|
||||
if self[:ensure] == :present and ! self[:password]
|
||||
raise ArgumentError, 'must set password when creating user' unless self[:password]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,59 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_user_permissions) do
|
||||
desc 'Type for managing rabbitmq user permissions'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:service) { 'rabbitmq-server' }
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'combination of user@vhost to grant privileges to'
|
||||
newvalues(/^\S+@\S+$/)
|
||||
end
|
||||
|
||||
newproperty(:configure_permission) do
|
||||
desc 'regexp representing configuration permissions'
|
||||
validate do |value|
|
||||
resource.validate_permissions(value)
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:read_permission) do
|
||||
desc 'regexp representing read permissions'
|
||||
validate do |value|
|
||||
resource.validate_permissions(value)
|
||||
end
|
||||
end
|
||||
|
||||
newproperty(:write_permission) do
|
||||
desc 'regexp representing write permissions'
|
||||
validate do |value|
|
||||
resource.validate_permissions(value)
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_vhost) do
|
||||
[self[:name].split('@')[1]]
|
||||
end
|
||||
|
||||
autorequire(:rabbitmq_user) do
|
||||
[self[:name].split('@')[0]]
|
||||
end
|
||||
|
||||
# I may want to dissalow whitespace
|
||||
def validate_permissions(value)
|
||||
begin
|
||||
Regexp.new(value)
|
||||
rescue RegexpError
|
||||
raise ArgumentError, "Invalid regexp #{value}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
Puppet::Type.newtype(:rabbitmq_vhost) do
|
||||
desc 'manages rabbitmq vhosts'
|
||||
|
||||
ensurable do
|
||||
defaultto(:present)
|
||||
newvalue(:present) do
|
||||
provider.create
|
||||
end
|
||||
newvalue(:absent) do
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:service) { 'rabbitmq-server' }
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
'name of the vhost to add'
|
||||
newvalues(/^\S+$/)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,109 +0,0 @@
|
|||
# Class: rabbitmq::config
|
||||
# Sets all the configuration values for RabbitMQ and creates the directories for
|
||||
# config and ssl.
|
||||
class rabbitmq::config {
|
||||
|
||||
$admin_enable = $rabbitmq::admin_enable
|
||||
$cluster_node_type = $rabbitmq::cluster_node_type
|
||||
$cluster_nodes = $rabbitmq::cluster_nodes
|
||||
$config = $rabbitmq::config
|
||||
$config_cluster = $rabbitmq::config_cluster
|
||||
$config_path = $rabbitmq::config_path
|
||||
$config_stomp = $rabbitmq::config_stomp
|
||||
$default_user = $rabbitmq::default_user
|
||||
$default_pass = $rabbitmq::default_pass
|
||||
$env_config = $rabbitmq::env_config
|
||||
$env_config_path = $rabbitmq::env_config_path
|
||||
$erlang_cookie = $rabbitmq::erlang_cookie
|
||||
$management_port = $rabbitmq::management_port
|
||||
$node_ip_address = $rabbitmq::node_ip_address
|
||||
$plugin_dir = $rabbitmq::plugin_dir
|
||||
$port = $rabbitmq::port
|
||||
$tcp_keepalive = $rabbitmq::tcp_keepalive
|
||||
$service_name = $rabbitmq::service_name
|
||||
$ssl = $rabbitmq::ssl
|
||||
$ssl_only = $rabbitmq::ssl_only
|
||||
$ssl_cacert = $rabbitmq::ssl_cacert
|
||||
$ssl_cert = $rabbitmq::ssl_cert
|
||||
$ssl_key = $rabbitmq::ssl_key
|
||||
$ssl_port = $rabbitmq::ssl_port
|
||||
$ssl_management_port = $rabbitmq::ssl_management_port
|
||||
$ssl_stomp_port = $rabbitmq::ssl_stomp_port
|
||||
$ssl_verify = $rabbitmq::ssl_verify
|
||||
$ssl_fail_if_no_peer_cert = $rabbitmq::ssl_fail_if_no_peer_cert
|
||||
$stomp_port = $rabbitmq::stomp_port
|
||||
$wipe_db_on_cookie_change = $rabbitmq::wipe_db_on_cookie_change
|
||||
$config_variables = $rabbitmq::config_variables
|
||||
$config_kernel_variables = $rabbitmq::config_kernel_variables
|
||||
$config_rabbitmq_management_variables = $rabbitmq::config_rabbitmq_management_variables
|
||||
$cluster_partition_handling = $rabbitmq::cluster_partition_handling
|
||||
$default_env_variables = {
|
||||
'NODE_PORT' => $port,
|
||||
'NODE_IP_ADDRESS' => $node_ip_address
|
||||
}
|
||||
|
||||
# Handle env variables.
|
||||
$environment_variables = merge($default_env_variables, $rabbitmq::environment_variables)
|
||||
|
||||
file { '/etc/rabbitmq':
|
||||
ensure => directory,
|
||||
owner => '0',
|
||||
group => '0',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { '/etc/rabbitmq/ssl':
|
||||
ensure => directory,
|
||||
owner => '0',
|
||||
group => '0',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { 'rabbitmq.config':
|
||||
ensure => file,
|
||||
path => $config_path,
|
||||
content => template($config),
|
||||
owner => '0',
|
||||
group => '0',
|
||||
mode => '0644',
|
||||
notify => Class['rabbitmq::service'],
|
||||
}
|
||||
|
||||
file { 'rabbitmq-env.config':
|
||||
ensure => file,
|
||||
path => $env_config_path,
|
||||
content => template($env_config),
|
||||
owner => '0',
|
||||
group => '0',
|
||||
mode => '0644',
|
||||
notify => Class['rabbitmq::service'],
|
||||
}
|
||||
|
||||
file { 'rabbitmqadmin.conf':
|
||||
ensure => file,
|
||||
path => '/etc/rabbitmq/rabbitmqadmin.conf',
|
||||
content => template('rabbitmq/rabbitmqadmin.conf.erb'),
|
||||
owner => '0',
|
||||
group => '0',
|
||||
mode => '0644',
|
||||
require => File['/etc/rabbitmq'],
|
||||
}
|
||||
|
||||
if $config_cluster {
|
||||
|
||||
if $erlang_cookie == undef {
|
||||
fail('You must set the $erlang_cookie value in order to configure clustering.')
|
||||
} else {
|
||||
rabbitmq_erlang_cookie { '/var/lib/rabbitmq/.erlang.cookie':
|
||||
content => $erlang_cookie,
|
||||
force => $wipe_db_on_cookie_change,
|
||||
service_name => $service_name,
|
||||
before => File['rabbitmq.config'],
|
||||
notify => Class['rabbitmq::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
# Main rabbitmq class
|
||||
class rabbitmq(
|
||||
$admin_enable = $rabbitmq::params::admin_enable,
|
||||
$cluster_node_type = $rabbitmq::params::cluster_node_type,
|
||||
$cluster_nodes = $rabbitmq::params::cluster_nodes,
|
||||
$config = $rabbitmq::params::config,
|
||||
$config_cluster = $rabbitmq::params::config_cluster,
|
||||
$config_path = $rabbitmq::params::config_path,
|
||||
$config_stomp = $rabbitmq::params::config_stomp,
|
||||
$default_user = $rabbitmq::params::default_user,
|
||||
$default_pass = $rabbitmq::params::default_pass,
|
||||
$delete_guest_user = $rabbitmq::params::delete_guest_user,
|
||||
$env_config = $rabbitmq::params::env_config,
|
||||
$env_config_path = $rabbitmq::params::env_config_path,
|
||||
$erlang_cookie = $rabbitmq::params::erlang_cookie,
|
||||
$management_port = $rabbitmq::params::management_port,
|
||||
$node_ip_address = $rabbitmq::params::node_ip_address,
|
||||
$package_apt_pin = $rabbitmq::params::package_apt_pin,
|
||||
$package_ensure = $rabbitmq::params::package_ensure,
|
||||
$package_gpg_key = $rabbitmq::params::package_gpg_key,
|
||||
$package_name = $rabbitmq::params::package_name,
|
||||
$package_provider = $rabbitmq::params::package_provider,
|
||||
$package_source = undef,
|
||||
$repos_ensure = $rabbitmq::params::repos_ensure,
|
||||
$manage_repos = $rabbitmq::params::manage_repos,
|
||||
$plugin_dir = $rabbitmq::params::plugin_dir,
|
||||
$port = $rabbitmq::params::port,
|
||||
$tcp_keepalive = $rabbitmq::params::tcp_keepalive,
|
||||
$service_ensure = $rabbitmq::params::service_ensure,
|
||||
$service_manage = $rabbitmq::params::service_manage,
|
||||
$service_name = $rabbitmq::params::service_name,
|
||||
$ssl = $rabbitmq::params::ssl,
|
||||
$ssl_only = $rabbitmq::params::ssl_only,
|
||||
$ssl_cacert = $rabbitmq::params::ssl_cacert,
|
||||
$ssl_cert = $rabbitmq::params::ssl_cert,
|
||||
$ssl_key = $rabbitmq::params::ssl_key,
|
||||
$ssl_port = $rabbitmq::params::ssl_port,
|
||||
$ssl_management_port = $rabbitmq::params::ssl_management_port,
|
||||
$ssl_stomp_port = $rabbitmq::params::ssl_stomp_port,
|
||||
$ssl_verify = $rabbitmq::params::ssl_verify,
|
||||
$ssl_fail_if_no_peer_cert = $rabbitmq::params::ssl_fail_if_no_peer_cert,
|
||||
$stomp_ensure = $rabbitmq::params::stomp_ensure,
|
||||
$ldap_auth = $rabbitmq::params::ldap_auth,
|
||||
$ldap_server = $rabbitmq::params::ldap_server,
|
||||
$ldap_user_dn_pattern = $rabbitmq::params::ldap_user_dn_pattern,
|
||||
$ldap_use_ssl = $rabbitmq::params::ldap_use_ssl,
|
||||
$ldap_port = $rabbitmq::params::ldap_port,
|
||||
$ldap_log = $rabbitmq::params::ldap_log,
|
||||
$stomp_port = $rabbitmq::params::stomp_port,
|
||||
$version = $rabbitmq::params::version,
|
||||
$wipe_db_on_cookie_change = $rabbitmq::params::wipe_db_on_cookie_change,
|
||||
$cluster_partition_handling = $rabbitmq::params::cluster_partition_handling,
|
||||
$environment_variables = $rabbitmq::params::environment_variables,
|
||||
$config_variables = $rabbitmq::params::config_variables,
|
||||
$config_kernel_variables = $rabbitmq::params::config_kernel_variables,
|
||||
$config_rabbitmq_management_variables = $rabbitmq::config_rabbitmq_management_variables,
|
||||
$key_content = undef,
|
||||
) inherits rabbitmq::params {
|
||||
|
||||
validate_bool($admin_enable)
|
||||
# Validate install parameters.
|
||||
validate_re($package_apt_pin, '^(|\d+)$')
|
||||
validate_string($package_ensure)
|
||||
validate_string($package_gpg_key)
|
||||
validate_string($package_name)
|
||||
validate_string($package_provider)
|
||||
validate_bool($repos_ensure)
|
||||
validate_re($version, '^\d+\.\d+\.\d+(-\d+)*$') # Allow 3 digits and optional -n postfix.
|
||||
# Validate config parameters.
|
||||
validate_re($cluster_node_type, '^(ram|disc|disk)$') # Both disc and disk are valid http://www.rabbitmq.com/clustering.html
|
||||
validate_array($cluster_nodes)
|
||||
validate_string($config)
|
||||
validate_absolute_path($config_path)
|
||||
validate_bool($config_cluster)
|
||||
validate_bool($config_stomp)
|
||||
validate_string($default_user)
|
||||
validate_string($default_pass)
|
||||
validate_bool($delete_guest_user)
|
||||
validate_string($env_config)
|
||||
validate_absolute_path($env_config_path)
|
||||
validate_string($erlang_cookie)
|
||||
validate_re($management_port, '\d+')
|
||||
validate_string($node_ip_address)
|
||||
validate_absolute_path($plugin_dir)
|
||||
validate_re($port, ['\d+','UNSET'])
|
||||
validate_re($stomp_port, '\d+')
|
||||
validate_bool($wipe_db_on_cookie_change)
|
||||
validate_bool($tcp_keepalive)
|
||||
# Validate service parameters.
|
||||
validate_re($service_ensure, '^(running|stopped)$')
|
||||
validate_bool($service_manage)
|
||||
validate_string($service_name)
|
||||
validate_bool($ssl)
|
||||
validate_bool($ssl_only)
|
||||
validate_string($ssl_cacert)
|
||||
validate_string($ssl_cert)
|
||||
validate_string($ssl_key)
|
||||
validate_re($ssl_port, '\d+')
|
||||
validate_re($ssl_management_port, '\d+')
|
||||
validate_string($ssl_stomp_port)
|
||||
validate_re($ssl_stomp_port, '\d+')
|
||||
validate_bool($stomp_ensure)
|
||||
validate_bool($ldap_auth)
|
||||
validate_string($ldap_server)
|
||||
validate_string($ldap_user_dn_pattern)
|
||||
validate_bool($ldap_use_ssl)
|
||||
validate_re($ldap_port, '\d+')
|
||||
validate_bool($ldap_log)
|
||||
validate_hash($environment_variables)
|
||||
validate_hash($config_variables)
|
||||
validate_hash($config_kernel_variables)
|
||||
validate_hash($config_rabbitmq_management_variables)
|
||||
|
||||
if $ssl_only and ! $ssl {
|
||||
fail('$ssl_only => true requires that $ssl => true')
|
||||
}
|
||||
|
||||
if $config_stomp and $ssl_stomp_port and ! $ssl {
|
||||
warning('$ssl_stomp_port requires that $ssl => true and will be ignored')
|
||||
}
|
||||
|
||||
# This needs to happen here instead of params.pp because
|
||||
# $package_source needs to override the constructed value in params.pp
|
||||
if $package_source { # $package_source was specified by user so use that one
|
||||
$real_package_source = $package_source
|
||||
# NOTE(bogdando) do not enforce the source value for yum provider #MODULES-1631
|
||||
} elsif $package_provider != 'yum' {
|
||||
# package_source was not specified, so construct it, unless the provider is 'yum'
|
||||
case $::osfamily {
|
||||
'RedHat', 'SUSE': {
|
||||
$base_version = regsubst($version,'^(.*)-\d$','\1')
|
||||
$real_package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v${base_version}/rabbitmq-server-${version}.noarch.rpm"
|
||||
}
|
||||
default: { # Archlinux and Debian
|
||||
$real_package_source = ''
|
||||
}
|
||||
}
|
||||
} else { # for yum provider, use the source as is
|
||||
$real_package_source = $package_source
|
||||
}
|
||||
|
||||
include '::rabbitmq::install'
|
||||
include '::rabbitmq::config'
|
||||
include '::rabbitmq::service'
|
||||
include '::rabbitmq::management'
|
||||
|
||||
if $manage_repos != undef {
|
||||
warning('$manage_repos is now deprecated. Please use $repos_ensure instead')
|
||||
}
|
||||
|
||||
if $manage_repos != false {
|
||||
case $::osfamily {
|
||||
'RedHat', 'SUSE':
|
||||
{ include '::rabbitmq::repo::rhel' }
|
||||
'Debian': {
|
||||
class { '::rabbitmq::repo::apt' :
|
||||
key_source => $package_gpg_key,
|
||||
key_content => $key_content,
|
||||
}
|
||||
}
|
||||
default:
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
# Start epmd as rabbitmq so it doesn't run as root when installing plugins
|
||||
exec { 'epmd_daemon':
|
||||
command => 'epmd -daemon',
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin',
|
||||
user => 'rabbitmq',
|
||||
group => 'rabbitmq',
|
||||
unless => 'pgrep epmd',
|
||||
}
|
||||
|
||||
if $admin_enable and $service_manage {
|
||||
include '::rabbitmq::install::rabbitmqadmin'
|
||||
|
||||
rabbitmq_plugin { 'rabbitmq_management':
|
||||
ensure => present,
|
||||
require => Class['rabbitmq::install'],
|
||||
notify => Class['rabbitmq::service'],
|
||||
provider => 'rabbitmqplugins'
|
||||
}
|
||||
|
||||
Class['::rabbitmq::service'] -> Class['::rabbitmq::install::rabbitmqadmin']
|
||||
}
|
||||
|
||||
if $stomp_ensure {
|
||||
rabbitmq_plugin { 'rabbitmq_stomp':
|
||||
ensure => present,
|
||||
require => Class['rabbitmq::install'],
|
||||
notify => Class['rabbitmq::service'],
|
||||
provider => 'rabbitmqplugins'
|
||||
}
|
||||
}
|
||||
|
||||
if ($ldap_auth) {
|
||||
rabbitmq_plugin { 'rabbitmq_auth_backend_ldap':
|
||||
ensure => present,
|
||||
require => Class['rabbitmq::install'],
|
||||
notify => Class['rabbitmq::service'],
|
||||
provider => 'rabbitmqplugins',
|
||||
}
|
||||
}
|
||||
|
||||
anchor { 'rabbitmq::begin': }
|
||||
anchor { 'rabbitmq::end': }
|
||||
|
||||
Anchor['rabbitmq::begin'] -> Class['::rabbitmq::install']
|
||||
-> Class['::rabbitmq::config'] ~> Class['::rabbitmq::service']
|
||||
-> Class['::rabbitmq::management'] -> Anchor['rabbitmq::end']
|
||||
|
||||
# Make sure the various providers have their requirements in place.
|
||||
Class['::rabbitmq::install'] -> Exec['epmd_daemon']
|
||||
-> Rabbitmq_plugin<| |> -> Rabbitmq_exchange<| |>
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# Class rabbitmq::install
|
||||
# Ensures the rabbitmq-server exists
|
||||
class rabbitmq::install {
|
||||
|
||||
$package_ensure = $rabbitmq::package_ensure
|
||||
$package_name = $rabbitmq::package_name
|
||||
$package_provider = $rabbitmq::package_provider
|
||||
$package_source = $rabbitmq::real_package_source
|
||||
|
||||
package { 'rabbitmq-server':
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
provider => $package_provider,
|
||||
notify => Class['rabbitmq::service'],
|
||||
}
|
||||
|
||||
if $package_source {
|
||||
Package['rabbitmq-server'] {
|
||||
source => $package_source,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#
|
||||
class rabbitmq::install::rabbitmqadmin {
|
||||
|
||||
if($rabbitmq::ssl) {
|
||||
$management_port = $rabbitmq::ssl_management_port
|
||||
}
|
||||
else {
|
||||
$management_port = $rabbitmq::management_port
|
||||
}
|
||||
|
||||
$default_user = $rabbitmq::default_user
|
||||
$default_pass = $rabbitmq::default_pass
|
||||
$protocol = $rabbitmq::ssl ? { false => 'http', default => 'https' }
|
||||
|
||||
staging::file { 'rabbitmqadmin':
|
||||
target => '/var/lib/rabbitmq/rabbitmqadmin',
|
||||
source => "${protocol}://${default_user}:${default_pass}@localhost:${management_port}/cli/rabbitmqadmin",
|
||||
curl_option => '-k --noproxy localhost --retry 30 --retry-delay 6',
|
||||
timeout => '180',
|
||||
wget_option => '--no-proxy',
|
||||
tries => 30,
|
||||
try_sleep => 6,
|
||||
require => [
|
||||
Class['rabbitmq::service'],
|
||||
Rabbitmq_plugin['rabbitmq_management']
|
||||
],
|
||||
}
|
||||
|
||||
file { '/usr/local/bin/rabbitmqadmin':
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
source => '/var/lib/rabbitmq/rabbitmqadmin',
|
||||
mode => '0755',
|
||||
require => Staging::File['rabbitmqadmin'],
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
class rabbitmq::management {
|
||||
|
||||
$delete_guest_user = $rabbitmq::delete_guest_user
|
||||
|
||||
if $delete_guest_user {
|
||||
rabbitmq_user{ 'guest':
|
||||
ensure => absent,
|
||||
provider => 'rabbitmqctl',
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
# Class: rabbitmq::params
|
||||
#
|
||||
# The RabbitMQ Module configuration settings.
|
||||
#
|
||||
class rabbitmq::params {
|
||||
|
||||
case $::osfamily {
|
||||
'Archlinux': {
|
||||
$package_ensure = 'installed'
|
||||
$package_name = 'rabbitmq'
|
||||
$service_name = 'rabbitmq'
|
||||
$version = '3.1.3-1'
|
||||
}
|
||||
'Debian': {
|
||||
$package_ensure = 'installed'
|
||||
$package_name = 'rabbitmq-server'
|
||||
$service_name = 'rabbitmq-server'
|
||||
$package_provider = 'apt'
|
||||
$version = '3.1.5'
|
||||
}
|
||||
'RedHat': {
|
||||
$package_ensure = 'installed'
|
||||
$package_name = 'rabbitmq-server'
|
||||
$service_name = 'rabbitmq-server'
|
||||
$package_provider = 'rpm'
|
||||
$version = '3.1.5-1'
|
||||
}
|
||||
'SUSE': {
|
||||
$package_ensure = 'installed'
|
||||
$package_name = 'rabbitmq-server'
|
||||
$service_name = 'rabbitmq-server'
|
||||
$package_provider = 'zypper'
|
||||
$version = '3.1.5-1'
|
||||
}
|
||||
default: {
|
||||
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
|
||||
}
|
||||
}
|
||||
|
||||
#install
|
||||
$admin_enable = true
|
||||
$management_port = '15672'
|
||||
$package_apt_pin = ''
|
||||
$package_gpg_key = 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
|
||||
$repos_ensure = true
|
||||
$manage_repos = undef
|
||||
$service_ensure = 'running'
|
||||
$service_manage = true
|
||||
#config
|
||||
$cluster_node_type = 'disc'
|
||||
$cluster_nodes = []
|
||||
$config = 'rabbitmq/rabbitmq.config.erb'
|
||||
$config_cluster = false
|
||||
$config_path = '/etc/rabbitmq/rabbitmq.config'
|
||||
$config_stomp = false
|
||||
$default_user = 'guest'
|
||||
$default_pass = 'guest'
|
||||
$delete_guest_user = false
|
||||
$env_config = 'rabbitmq/rabbitmq-env.conf.erb'
|
||||
$env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
|
||||
$erlang_cookie = undef
|
||||
$node_ip_address = 'UNSET'
|
||||
$plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins"
|
||||
$port = '5672'
|
||||
$tcp_keepalive = false
|
||||
$ssl = false
|
||||
$ssl_only = false
|
||||
$ssl_cacert = 'UNSET'
|
||||
$ssl_cert = 'UNSET'
|
||||
$ssl_key = 'UNSET'
|
||||
$ssl_port = '5671'
|
||||
$ssl_management_port = '15671'
|
||||
$ssl_stomp_port = '6164'
|
||||
$ssl_verify = 'verify_none'
|
||||
$ssl_fail_if_no_peer_cert = false
|
||||
$stomp_ensure = false
|
||||
$ldap_auth = false
|
||||
$ldap_server = 'ldap'
|
||||
$ldap_user_dn_pattern = 'cn=username,ou=People,dc=example,dc=com'
|
||||
$ldap_use_ssl = false
|
||||
$ldap_port = '389'
|
||||
$ldap_log = false
|
||||
$stomp_port = '6163'
|
||||
$wipe_db_on_cookie_change = false
|
||||
$cluster_partition_handling = 'ignore'
|
||||
$environment_variables = {}
|
||||
$config_variables = {}
|
||||
$config_rabbitmq_management_variables = {}
|
||||
$config_kernel_variables = {}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
# requires
|
||||
# puppetlabs-apt
|
||||
# puppetlabs-stdlib
|
||||
class rabbitmq::repo::apt(
|
||||
$location = 'http://www.rabbitmq.com/debian/',
|
||||
$release = 'testing',
|
||||
$repos = 'main',
|
||||
$include_src = false,
|
||||
$key = 'F7B8CEA6056E8E56',
|
||||
$key_source = 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc',
|
||||
$key_content = undef,
|
||||
) {
|
||||
|
||||
$pin = $rabbitmq::package_apt_pin
|
||||
|
||||
Class['rabbitmq::repo::apt'] -> Package<| title == 'rabbitmq-server' |>
|
||||
|
||||
$ensure_source = $rabbitmq::repos_ensure ? {
|
||||
false => 'absent',
|
||||
default => 'present',
|
||||
}
|
||||
|
||||
apt::source { 'rabbitmq':
|
||||
ensure => $ensure_source,
|
||||
location => $location,
|
||||
release => $release,
|
||||
repos => $repos,
|
||||
include_src => $include_src,
|
||||
key => $key,
|
||||
key_source => $key_source,
|
||||
key_content => $key_content,
|
||||
}
|
||||
|
||||
if $pin {
|
||||
validate_re($pin, '\d\d\d')
|
||||
apt::pin { 'rabbitmq':
|
||||
packages => 'rabbitmq-server',
|
||||
priority => $pin,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
# Class: rabbitmq::repo::rhel
|
||||
# Imports the gpg key if it doesn't already exist.
|
||||
class rabbitmq::repo::rhel {
|
||||
|
||||
if $rabbitmq::repos_ensure {
|
||||
|
||||
$package_gpg_key = $rabbitmq::package_gpg_key
|
||||
|
||||
Class['rabbitmq::repo::rhel'] -> Package<| title == 'rabbitmq-server' |>
|
||||
|
||||
exec { "rpm --import ${package_gpg_key}":
|
||||
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
|
||||
unless => 'rpm -q gpg-pubkey-056e8e56-468e43f2 2>/dev/null',
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
# Class: rabbitmq::server
|
||||
#
|
||||
# This module manages the installation and config of the rabbitmq server
|
||||
# it has only been tested on certain version of debian-ish systems
|
||||
# Parameters:
|
||||
# [*port*] - port where rabbitmq server is hosted
|
||||
# [*delete_guest_user*] - rather or not to delete the default user
|
||||
# [*version*] - version of rabbitmq-server to install
|
||||
# [*package_name*] - name of rabbitmq package
|
||||
# [*service_name*] - name of rabbitmq service
|
||||
# [*service_ensure*] - desired ensure state for service
|
||||
# [*stomp_port*] - port stomp should be listening on
|
||||
# [*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_nodes*] - which nodes to cluster with (including the current one)
|
||||
# [*cluster_node_type*] - Type of cluster node (disc/disk or ram)
|
||||
# [*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:
|
||||
#
|
||||
# This module is used as backward compability layer for modules
|
||||
# which require rabbitmq::server instead of rabbitmq class.
|
||||
# It's still common uasge in many modules.
|
||||
#
|
||||
#
|
||||
# [Remember: No empty lines between comments and class definition]
|
||||
class rabbitmq::server(
|
||||
$port = $rabbitmq::params::port,
|
||||
$delete_guest_user = $rabbitmq::params::delete_guest_user,
|
||||
$package_name = $rabbitmq::params::package_name,
|
||||
$version = $rabbitmq::params::version,
|
||||
$service_name = $rabbitmq::params::service_name,
|
||||
$service_ensure = $rabbitmq::params::service_ensure,
|
||||
$service_manage = $rabbitmq::params::service_manage,
|
||||
$config_stomp = $rabbitmq::params::config_stomp,
|
||||
$stomp_port = $rabbitmq::params::stomp_port,
|
||||
$config_cluster = $rabbitmq::params::config_cluster,
|
||||
$cluster_nodes = $rabbitmq::params::cluster_nodes,
|
||||
$cluster_node_type = $rabbitmq::params::cluster_node_type,
|
||||
$node_ip_address = $rabbitmq::params::node_ip_address,
|
||||
$config = $rabbitmq::params::config,
|
||||
$env_config = $rabbitmq::params::env_config,
|
||||
$erlang_cookie = $rabbitmq::params::erlang_cookie,
|
||||
$wipe_db_on_cookie_change = $rabbitmq::params::wipe_db_on_cookie_change,
|
||||
) inherits rabbitmq::params {
|
||||
|
||||
anchor {'before::rabbimq::class':
|
||||
before => Class['rabbitmq'],
|
||||
}
|
||||
|
||||
anchor {'after::rabbimq::class':
|
||||
require => Class['rabbitmq'],
|
||||
}
|
||||
|
||||
class { 'rabbitmq':
|
||||
port => $port,
|
||||
delete_guest_user => $delete_guest_user,
|
||||
package_name => $package_name,
|
||||
version => $version,
|
||||
service_name => $service_name,
|
||||
service_ensure => $service_ensure,
|
||||
service_manage => $service_manage,
|
||||
config_stomp => $config_stomp,
|
||||
stomp_port => $stomp_port,
|
||||
config_cluster => $config_cluster,
|
||||
cluster_nodes => $cluster_nodes,
|
||||
cluster_node_type => $cluster_node_type,
|
||||
node_ip_address => $node_ip_address,
|
||||
config => $config,
|
||||
env_config => $env_config,
|
||||
erlang_cookie => $erlang_cookie,
|
||||
wipe_db_on_cookie_change => $wipe_db_on_cookie_change,
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
# Class: rabbitmq::service
|
||||
#
|
||||
# This class manages the rabbitmq server service itself.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class rabbitmq::service(
|
||||
$service_ensure = $rabbitmq::service_ensure,
|
||||
$service_manage = $rabbitmq::service_manage,
|
||||
$service_name = $rabbitmq::service_name,
|
||||
) inherits rabbitmq {
|
||||
|
||||
validate_re($service_ensure, '^(running|stopped)$')
|
||||
validate_bool($service_manage)
|
||||
|
||||
if ($service_manage) {
|
||||
if $service_ensure == 'running' {
|
||||
$ensure_real = 'running'
|
||||
$enable_real = true
|
||||
} else {
|
||||
$ensure_real = 'stopped'
|
||||
$enable_real = false
|
||||
}
|
||||
|
||||
service { 'rabbitmq-server':
|
||||
ensure => $ensure_real,
|
||||
enable => $enable_real,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
name => $service_name,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"name": "puppetlabs-rabbitmq",
|
||||
"version": "5.0.0",
|
||||
"author": "puppetlabs",
|
||||
"summary": "Installs, configures, and manages RabbitMQ.",
|
||||
"license": "Apache-2.0",
|
||||
"source": "https://github.com/puppetlabs/puppetlabs-rabbitmq",
|
||||
"project_page": "https://github.com/puppetlabs/puppetlabs-rabbitmq",
|
||||
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "RedHat",
|
||||
"operatingsystemrelease": [
|
||||
"5",
|
||||
"6"
|
||||
]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "CentOS",
|
||||
"operatingsystemrelease": [
|
||||
"5",
|
||||
"6"
|
||||
]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "Debian",
|
||||
"operatingsystemrelease": [
|
||||
"6",
|
||||
"7"
|
||||
]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": [
|
||||
"12.04",
|
||||
"14.04"
|
||||
]
|
||||
}
|
||||
],
|
||||
"requirements": [
|
||||
{
|
||||
"name": "pe",
|
||||
"version_requirement": "3.x"
|
||||
},
|
||||
{
|
||||
"name": "puppet",
|
||||
"version_requirement": "3.x"
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{ "name": "puppetlabs/stdlib", "version_requirement": ">=2.0.0 <5.0.0" },
|
||||
{ "name": "puppetlabs/apt", "version_requirement": ">=1.0.0 <2.0.0" },
|
||||
{ "name": "nanliu/staging", "version_requirement": ">=0.3.1 <2.0.0" }
|
||||
]
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
Specs
|
||||
=====
|
||||
|
||||
The Puppet project uses RSpec for testing.
|
||||
|
||||
For more information on RSpec, see http://rspec.info/
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq class:' do
|
||||
case fact('osfamily')
|
||||
when 'RedHat'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'SUSE'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'Debian'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'Archlinux'
|
||||
package_name = 'rabbitmq'
|
||||
service_name = 'rabbitmq'
|
||||
end
|
||||
|
||||
context "default class inclusion" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq': }
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
# Apply twice to ensure no errors the second time.
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
expect(apply_manifest(pp, :catch_changes => true).exit_code).to be_zero
|
||||
end
|
||||
|
||||
describe package(package_name) do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "disable and stop service" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
service_ensure => 'stopped',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should_not be_enabled }
|
||||
it { should_not be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "service is unmanaged" do
|
||||
it 'should run successfully' do
|
||||
pp_pre = <<-EOS
|
||||
class { 'rabbitmq': }
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
service_manage => false,
|
||||
service_ensure => 'stopped',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp_pre, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq clustering' do
|
||||
context 'rabbitmq::wipe_db_on_cookie_change => false' do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
config_cluster => true,
|
||||
cluster_nodes => ['rabbit1', 'rabbit2'],
|
||||
cluster_node_type => 'ram',
|
||||
erlang_cookie => 'TESTCOOKIE',
|
||||
wipe_db_on_cookie_change => false,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true)
|
||||
end
|
||||
|
||||
describe file('/var/lib/rabbitmq/.erlang.cookie') do
|
||||
it { should_not contain 'TESTCOOKIE' }
|
||||
end
|
||||
|
||||
end
|
||||
context 'rabbitmq::wipe_db_on_cookie_change => true' do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
config_cluster => true,
|
||||
cluster_nodes => ['rabbit1', 'rabbit2'],
|
||||
cluster_node_type => 'ram',
|
||||
erlang_cookie => 'TESTCOOKIE',
|
||||
wipe_db_on_cookie_change => true,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/rabbitmq/rabbitmq.config') do
|
||||
it { should be_file }
|
||||
it { should contain 'cluster_nodes' }
|
||||
it { should contain 'rabbit@rabbit1' }
|
||||
it { should contain 'rabbit@rabbit2' }
|
||||
it { should contain 'ram' }
|
||||
end
|
||||
|
||||
describe file('/var/lib/rabbitmq/.erlang.cookie') do
|
||||
it { should be_file }
|
||||
it { should contain 'TESTCOOKIE' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq with delete_guest_user' do
|
||||
context 'delete_guest_user' do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
shell('rabbitmqctl list_users > /tmp/rabbitmqctl_users')
|
||||
end
|
||||
|
||||
describe file('/tmp/rabbitmqctl_users') do
|
||||
it { should be_file }
|
||||
it { should_not contain 'guest' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
HOSTS:
|
||||
centos-64-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: el-6-x86_64
|
||||
box : centos-64-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
log_level: debug
|
||||
type: git
|
|
@ -1,11 +0,0 @@
|
|||
HOSTS:
|
||||
ubuntu-server-1310-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-13.10-amd64
|
||||
box : ubuntu-server-1310-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-1310-x64-virtualbox-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
log_level : debug
|
||||
type: git
|
|
@ -1,11 +0,0 @@
|
|||
HOSTS:
|
||||
ubuntu-server-1404-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-14.04-amd64
|
||||
box : trusty-server-cloudimg-amd64-vagrant-disk1
|
||||
box_url : https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
log_level : debug
|
||||
type: git
|
|
@ -1,47 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq policy on a vhost:' do
|
||||
|
||||
|
||||
context "create policy resource" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true }
|
||||
Class['erlang'] -> Class['::rabbitmq']
|
||||
}
|
||||
class { '::rabbitmq':
|
||||
service_manage => true,
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
admin_enable => true,
|
||||
} ->
|
||||
|
||||
rabbitmq_vhost { 'myhost':
|
||||
ensure => present,
|
||||
} ->
|
||||
|
||||
rabbitmq_policy { 'ha-all@myhost':
|
||||
pattern => '.*',
|
||||
priority => 0,
|
||||
applyto => 'all',
|
||||
definition => {
|
||||
'ha-mode' => 'all',
|
||||
'ha-sync-mode' => 'automatic',
|
||||
},
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
end
|
||||
|
||||
it 'should have the policy' do
|
||||
shell('rabbitmqctl list_policies -p myhost') do |r|
|
||||
expect(r.stdout).to match(/myhost.*ha-all.*ha-sync-mode/)
|
||||
expect(r.exit_code).to be_zero
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,85 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq::install::rabbitmqadmin class' do
|
||||
context 'does nothing if service is unmanaged' do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
admin_enable => true,
|
||||
service_manage => false,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
|
||||
context 'downloads the cli tools' do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
admin_enable => true,
|
||||
service_manage => true,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
|
||||
context 'works with specified default credentials' do
|
||||
it 'should run successfully' do
|
||||
# make sure credential change takes effect before admin_enable
|
||||
pp_pre = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
service_manage => true,
|
||||
default_user => 'foobar',
|
||||
default_pass => 'bazblam',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
admin_enable => true,
|
||||
service_manage => true,
|
||||
default_user => 'foobar',
|
||||
default_pass => 'bazblam',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
|
||||
apply_manifest(pp_pre, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,96 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq server:' do
|
||||
case fact('osfamily')
|
||||
when 'RedHat'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'SUSE'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'Debian'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
when 'Archlinux'
|
||||
package_name = 'rabbitmq'
|
||||
service_name = 'rabbitmq'
|
||||
end
|
||||
|
||||
context "default class inclusion" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq::server': }
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq::server']
|
||||
}
|
||||
EOS
|
||||
|
||||
# Apply twice to ensure no errors the second time.
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
expect(apply_manifest(pp, :catch_changes => true).exit_code).to be_zero
|
||||
end
|
||||
|
||||
describe package(package_name) do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "disable and stop service" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq::server':
|
||||
service_ensure => 'stopped',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq::server']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should_not be_enabled }
|
||||
it { should_not be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "service is unmanaged" do
|
||||
it 'should run successfully' do
|
||||
pp_pre = <<-EOS
|
||||
class { 'rabbitmq::server': }
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq::server']
|
||||
}
|
||||
EOS
|
||||
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq::server':
|
||||
service_manage => false,
|
||||
service_ensure => 'stopped',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq::server']
|
||||
}
|
||||
EOS
|
||||
|
||||
|
||||
apply_manifest(pp_pre, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq user:' do
|
||||
|
||||
|
||||
context "create user resource" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true }
|
||||
Class['erlang'] -> Class['::rabbitmq']
|
||||
}
|
||||
class { '::rabbitmq':
|
||||
service_manage => true,
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
admin_enable => true,
|
||||
} ->
|
||||
|
||||
rabbitmq_user { 'dan':
|
||||
admin => true,
|
||||
password => 'bar',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
end
|
||||
|
||||
it 'should have the user' do
|
||||
shell('rabbitmqctl list_users') do |r|
|
||||
expect(r.stdout).to match(/dan.*administrator/)
|
||||
expect(r.exit_code).to be_zero
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rabbitmq vhost:' do
|
||||
|
||||
|
||||
context "create vhost resource" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true }
|
||||
Class['erlang'] -> Class['::rabbitmq']
|
||||
}
|
||||
class { '::rabbitmq':
|
||||
service_manage => true,
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
admin_enable => true,
|
||||
} ->
|
||||
|
||||
rabbitmq_vhost { 'myhost':
|
||||
ensure => present,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_changes => true)
|
||||
end
|
||||
|
||||
it 'should have the vhost' do
|
||||
shell('rabbitmqctl list_vhosts') do |r|
|
||||
expect(r.stdout).to match(/myhost/)
|
||||
expect(r.exit_code).to be_zero
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,213 +0,0 @@
|
|||
require 'spec_helper_acceptance'
|
||||
#
|
||||
# beacuse of some serious issues with upgrading and downgrading rabbitmq on RedHat,
|
||||
# we need to run all of the 2.8.1 tests last.
|
||||
#
|
||||
# NOTE that this is only tested on RedHat and probably only works there. But I can't seem
|
||||
# to get 'confine' to work...
|
||||
#
|
||||
|
||||
describe 'rabbitmq class with 2.8.1:' do
|
||||
case fact('osfamily')
|
||||
when 'RedHat'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.1/rabbitmq-server-2.8.1-1.noarch.rpm"
|
||||
package_ensure = '2.8.1-1'
|
||||
when 'SUSE'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
package_source = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.1/rabbitmq-server-2.8.1-1.noarch.rpm"
|
||||
package_ensure = '2.8.1-1'
|
||||
when 'Debian'
|
||||
package_name = 'rabbitmq-server'
|
||||
service_name = 'rabbitmq-server'
|
||||
package_source = ''
|
||||
package_ensure = '2.8.1'
|
||||
when 'Archlinux'
|
||||
package_name = 'rabbitmq'
|
||||
service_name = 'rabbitmq'
|
||||
package_source = ''
|
||||
package_ensure = '2.8.1'
|
||||
end
|
||||
|
||||
context "default class inclusion" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
version => '2.8.1-1',
|
||||
package_source => '#{package_source}',
|
||||
package_ensure => '#{package_ensure}',
|
||||
package_provider => 'rpm',
|
||||
management_port => '55672',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
# clean up previous 3.x install - can't be ungraded cleanly via RPM
|
||||
shell('service rabbitmq-server stop')
|
||||
shell('yum -y erase rabbitmq-server')
|
||||
shell('rm -Rf /var/lib/rabbitmq/mnesia /etc/rabbitmq /var/lib/rabbitmq/rabbitmqadmin')
|
||||
# Apply twice to ensure no errors the second time.
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
expect(apply_manifest(pp, :catch_changes => true).exit_code).to be_zero
|
||||
# DEBUG
|
||||
shell('netstat -lntp')
|
||||
end
|
||||
|
||||
describe command('rabbitmqctl status') do
|
||||
its(:stdout) { should match /{rabbit,"RabbitMQ","2.8.1"}/ }
|
||||
end
|
||||
|
||||
describe package(package_name) do
|
||||
it { should be_installed }
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "disable and stop service" do
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
version => '2.8.1-1',
|
||||
package_source => '#{package_source}',
|
||||
package_ensure => '#{package_ensure}',
|
||||
package_provider => 'rpm',
|
||||
management_port => '55672',
|
||||
service_ensure => 'stopped',
|
||||
admin_enable => false,
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should_not be_enabled }
|
||||
it { should_not be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context "service is unmanaged" do
|
||||
it 'should run successfully' do
|
||||
pp_pre = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
version => '2.8.1-1',
|
||||
package_source => '#{package_source}',
|
||||
package_ensure => '#{package_ensure}',
|
||||
package_provider => 'rpm',
|
||||
management_port => '55672',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
service_manage => false,
|
||||
service_ensure => 'stopped',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp_pre, :catch_failures => true)
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
end
|
||||
|
||||
context 'rabbitmqadmin' do
|
||||
#confine :to, :platform => 'el-6-x86'
|
||||
|
||||
it 'should run successfully' do
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
admin_enable => true,
|
||||
service_manage => true,
|
||||
version => '2.8.1-1',
|
||||
package_source => '#{package_source}',
|
||||
package_ensure => '#{package_ensure}',
|
||||
package_provider => 'rpm',
|
||||
management_port => '55672',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
# since serverspec (used by beaker-rspec) can only tell present/absent for packages
|
||||
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
|
||||
it { should be_file }
|
||||
end
|
||||
|
||||
describe command('rabbitmqadmin --help') do
|
||||
it { should return_exit_status 0 }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'rabbitmqadmin with specified default credentials' do
|
||||
|
||||
it 'should run successfully' do
|
||||
# make sure credential change takes effect before admin_enable
|
||||
pp = <<-EOS
|
||||
class { 'rabbitmq':
|
||||
admin_enable => true,
|
||||
service_manage => true,
|
||||
version => '2.8.1-1',
|
||||
package_source => '#{package_source}',
|
||||
package_ensure => '#{package_ensure}',
|
||||
package_provider => 'rpm',
|
||||
management_port => '55672',
|
||||
default_user => 'foobar',
|
||||
default_pass => 'bazblam',
|
||||
}
|
||||
if $::osfamily == 'RedHat' {
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
||||
}
|
||||
EOS
|
||||
|
||||
# next 3 lines - see MODULES-1085
|
||||
shell('service rabbitmq-server stop')
|
||||
shell('rm -Rf /var/lib/rabbitmq/mnesia /var/lib/rabbitmq/rabbitmqadmin')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
# since serverspec (used by beaker-rspec) can only tell present/absent for packages
|
||||
describe file('/var/lib/rabbitmq/rabbitmqadmin') do
|
||||
it { should be_file }
|
||||
end
|
||||
|
||||
describe command('rabbitmqadmin --help') do
|
||||
it { should return_exit_status 0 }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,794 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'rabbitmq' do
|
||||
|
||||
context 'on unsupported distributions' do
|
||||
let(:facts) {{ :osfamily => 'Unsupported' }}
|
||||
|
||||
it 'we fail' do
|
||||
expect { subject }.to raise_error(/not supported on an Unsupported/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
it 'includes rabbitmq::repo::apt' do
|
||||
should contain_class('rabbitmq::repo::apt')
|
||||
end
|
||||
|
||||
describe 'apt::source default values' do
|
||||
it 'should add a repo with defaults values' do
|
||||
should contain_apt__source('rabbitmq').with( {
|
||||
:ensure => 'present',
|
||||
:location => 'http://www.rabbitmq.com/debian/',
|
||||
:release => 'testing',
|
||||
:repos => 'main',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => false }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
it 'does ensure rabbitmq apt::source is absent when manage_repos is false' do
|
||||
should_not contain_apt__source('rabbitmq')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => true }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
|
||||
it 'includes rabbitmq::repo::apt' do
|
||||
should contain_class('rabbitmq::repo::apt')
|
||||
end
|
||||
|
||||
describe 'apt::source default values' do
|
||||
it 'should add a repo with defaults values' do
|
||||
should contain_apt__source('rabbitmq').with( {
|
||||
:ensure => 'present',
|
||||
:location => 'http://www.rabbitmq.com/debian/',
|
||||
:release => 'testing',
|
||||
:repos => 'main',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
it 'does ensure rabbitmq apt::source is absent when repos_ensure is false' do
|
||||
should contain_apt__source('rabbitmq').with(
|
||||
'ensure' => 'absent'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
|
||||
it 'includes rabbitmq::repo::apt' do
|
||||
should contain_class('rabbitmq::repo::apt')
|
||||
end
|
||||
|
||||
describe 'apt::source default values' do
|
||||
it 'should add a repo with defaults values' do
|
||||
should contain_apt__source('rabbitmq').with( {
|
||||
:ensure => 'present',
|
||||
:location => 'http://www.rabbitmq.com/debian/',
|
||||
:release => 'testing',
|
||||
:repos => 'main',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => true, :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
|
||||
it 'includes rabbitmq::repo::apt' do
|
||||
should contain_class('rabbitmq::repo::apt')
|
||||
end
|
||||
|
||||
describe 'apt::source default values' do
|
||||
it 'should add a repo with defaults values' do
|
||||
should contain_apt__source('rabbitmq').with( {
|
||||
:ensure => 'absent',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => true, :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
|
||||
it 'includes rabbitmq::repo::apt' do
|
||||
should contain_class('rabbitmq::repo::apt')
|
||||
end
|
||||
|
||||
describe 'apt::source default values' do
|
||||
it 'should add a repo with defaults values' do
|
||||
should contain_apt__source('rabbitmq').with( {
|
||||
:ensure => 'present',
|
||||
:location => 'http://www.rabbitmq.com/debian/',
|
||||
:release => 'testing',
|
||||
:repos => 'main',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => false, :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
it 'does ensure rabbitmq apt::source is absent when manage_repos is false and repos_ensure is true' do
|
||||
should_not contain_apt__source('rabbitmq')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
let(:params) {{ :manage_repos => false, :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'squeeze' }}
|
||||
it 'does ensure rabbitmq apt::source is absent when manage_repos is false and repos_ensure is false' do
|
||||
should_not contain_apt__source('rabbitmq')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'includes rabbitmq::repo::rhel' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does not import repo public key when repos_ensure is false' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does import repo public key when repos_ensure is true' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => false }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does not import repo public key when manage_repos is false' do
|
||||
should_not contain_class('rabbitmq::repo::rhel')
|
||||
should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => true }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does import repo public key when manage_repos is true' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => false, :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does not import repo public key when manage_repos is false and repos_ensure is true' do
|
||||
should_not contain_class('rabbitmq::repo::rhel')
|
||||
should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => true, :repos_ensure => true }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does import repo public key when manage_repos is true and repos_ensure is true' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => false, :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does not import repo public key when manage_repos is false and repos_ensure is false' do
|
||||
should_not contain_class('rabbitmq::repo::rhel')
|
||||
should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat' do
|
||||
let(:params) {{ :manage_repos => true, :repos_ensure => false }}
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
it 'does not import repo public key when manage_repos is true and repos_ensure is false' do
|
||||
should contain_class('rabbitmq::repo::rhel')
|
||||
should_not contain_exec('rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
|
||||
end
|
||||
end
|
||||
|
||||
['Debian', 'RedHat', 'SUSE', 'Archlinux'].each do |distro|
|
||||
context "on #{distro}" do
|
||||
let(:facts) {{
|
||||
:osfamily => distro,
|
||||
:lsbdistcodename => 'squeeze',
|
||||
:lsbdistid => 'Debian'
|
||||
}}
|
||||
|
||||
it { should contain_class('rabbitmq::install') }
|
||||
it { should contain_class('rabbitmq::config') }
|
||||
it { should contain_class('rabbitmq::service') }
|
||||
|
||||
|
||||
context 'with admin_enable set to true' do
|
||||
let(:params) {{ :admin_enable => true }}
|
||||
context 'with service_manage set to true' do
|
||||
it 'we enable the admin interface by default' do
|
||||
should contain_class('rabbitmq::install::rabbitmqadmin')
|
||||
should contain_rabbitmq_plugin('rabbitmq_management').with(
|
||||
'require' => 'Class[Rabbitmq::Install]',
|
||||
'notify' => 'Class[Rabbitmq::Service]'
|
||||
)
|
||||
should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:15672/cli/rabbitmqadmin")
|
||||
end
|
||||
end
|
||||
context 'with service_manage set to true and default user/pass specified' do
|
||||
let(:params) {{ :admin_enable => true, :default_user => 'foobar', :default_pass => 'hunter2' }}
|
||||
it 'we use the correct URL to rabbitmqadmin' do
|
||||
should contain_staging__file('rabbitmqadmin').with_source("http://foobar:hunter2@localhost:15672/cli/rabbitmqadmin")
|
||||
end
|
||||
end
|
||||
context 'with service_manage set to true and management port specified' do
|
||||
# note that the 2.x management port is 55672 not 15672
|
||||
let(:params) {{ :admin_enable => true, :management_port => '55672' }}
|
||||
it 'we use the correct URL to rabbitmqadmin' do
|
||||
should contain_staging__file('rabbitmqadmin').with_source("http://guest:guest@localhost:55672/cli/rabbitmqadmin")
|
||||
end
|
||||
end
|
||||
context 'with service_manage set to false' do
|
||||
let(:params) {{ :admin_enable => true, :service_manage => false }}
|
||||
it 'should do nothing' do
|
||||
should_not contain_class('rabbitmq::install::rabbitmqadmin')
|
||||
should_not contain_rabbitmq_plugin('rabbitmq_management')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'manages configuration directory correctly' do
|
||||
it { should contain_file('/etc/rabbitmq').with(
|
||||
'ensure' => 'directory'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'manages configuration file correctly' do
|
||||
it { should contain_file('rabbitmq.config') }
|
||||
end
|
||||
|
||||
context 'configures config_cluster' do
|
||||
let(:facts) {{ :osfamily => distro, :lsbdistid => 'Debian' }}
|
||||
let(:params) {{
|
||||
:config_cluster => true,
|
||||
:cluster_nodes => ['hare-1', 'hare-2'],
|
||||
:cluster_node_type => 'ram',
|
||||
:wipe_db_on_cookie_change => false
|
||||
}}
|
||||
|
||||
describe 'with defaults' do
|
||||
it 'fails' do
|
||||
expect{subject}.to raise_error(/^You must set the \$erlang_cookie value/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with erlang_cookie set' do
|
||||
let(:params) {{
|
||||
:config_cluster => true,
|
||||
:cluster_nodes => ['hare-1', 'hare-2'],
|
||||
:cluster_node_type => 'ram',
|
||||
:erlang_cookie => 'TESTCOOKIE',
|
||||
:wipe_db_on_cookie_change => true
|
||||
}}
|
||||
it 'contains the rabbitmq_erlang_cookie' do
|
||||
should contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'and sets appropriate configuration' do
|
||||
let(:params) {{
|
||||
:config_cluster => true,
|
||||
:cluster_nodes => ['hare-1', 'hare-2'],
|
||||
:cluster_node_type => 'ram',
|
||||
:erlang_cookie => 'ORIGINAL',
|
||||
:wipe_db_on_cookie_change => true
|
||||
}}
|
||||
it 'for cluster_nodes' do
|
||||
should contain_file('rabbitmq.config').with({
|
||||
'content' => /cluster_nodes.*\['rabbit@hare-1', 'rabbit@hare-2'\], ram/,
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rabbitmq-env configuration' do
|
||||
let(:params) {{ :environment_variables => {
|
||||
'NODE_IP_ADDRESS' => '1.1.1.1',
|
||||
'NODE_PORT' => '5656',
|
||||
'NODENAME' => 'HOSTNAME',
|
||||
'SERVICENAME' => 'RabbitMQ',
|
||||
'CONSOLE_LOG' => 'RabbitMQ.debug',
|
||||
'CTL_ERL_ARGS' => 'verbose',
|
||||
'SERVER_ERL_ARGS' => 'v',
|
||||
'SERVER_START_ARGS' => 'debug'
|
||||
}}}
|
||||
it 'should set environment variables' do
|
||||
should contain_file('rabbitmq-env.config') \
|
||||
.with_content(/NODE_IP_ADDRESS=1.1.1.1/) \
|
||||
.with_content(/NODE_PORT=5656/) \
|
||||
.with_content(/NODENAME=HOSTNAME/) \
|
||||
.with_content(/SERVICENAME=RabbitMQ/) \
|
||||
.with_content(/CONSOLE_LOG=RabbitMQ.debug/) \
|
||||
.with_content(/CTL_ERL_ARGS=verbose/) \
|
||||
.with_content(/SERVER_ERL_ARGS=v/) \
|
||||
.with_content(/SERVER_START_ARGS=debug/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'delete_guest_user' do
|
||||
describe 'should do nothing by default' do
|
||||
it { should_not contain_rabbitmq_user('guest') }
|
||||
end
|
||||
|
||||
describe 'delete user when delete_guest_user set' do
|
||||
let(:params) {{ :delete_guest_user => true }}
|
||||
it 'removes the user' do
|
||||
should contain_rabbitmq_user('guest').with(
|
||||
'ensure' => 'absent',
|
||||
'provider' => 'rabbitmqctl'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'configuration setting' do
|
||||
describe 'node_ip_address when set' do
|
||||
let(:params) {{ :node_ip_address => '172.0.0.1' }}
|
||||
it 'should set NODE_IP_ADDRESS to specified value' do
|
||||
should contain_file('rabbitmq-env.config').
|
||||
with_content(%r{NODE_IP_ADDRESS=172\.0\.0\.1})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stomp by default' do
|
||||
it 'should not specify stomp parameters in rabbitmq.config' do
|
||||
should contain_file('rabbitmq.config').without({
|
||||
'content' => /stomp/,})
|
||||
end
|
||||
end
|
||||
describe 'stomp when set' do
|
||||
let(:params) {{ :config_stomp => true, :stomp_port => 5679 }}
|
||||
it 'should specify stomp port in rabbitmq.config' do
|
||||
should contain_file('rabbitmq.config').with({
|
||||
'content' => /rabbitmq_stomp.*tcp_listeners, \[5679\]/m,
|
||||
})
|
||||
end
|
||||
end
|
||||
describe 'stomp when set ssl port w/o ssl enabled' do
|
||||
let(:params) {{ :config_stomp => true, :stomp_port => 5679, :ssl => false, :ssl_stomp_port => 5680 }}
|
||||
it 'should not configure ssl_listeners in rabbitmq.config' do
|
||||
should contain_file('rabbitmq.config').without({
|
||||
'content' => /rabbitmq_stomp.*ssl_listeners, \[5680\]/m,
|
||||
})
|
||||
end
|
||||
end
|
||||
describe 'stomp when set with ssl' do
|
||||
let(:params) {{ :config_stomp => true, :stomp_port => 5679, :ssl => true, :ssl_stomp_port => 5680 }}
|
||||
it 'should specify stomp port and ssl stomp port in rabbitmq.config' do
|
||||
should contain_file('rabbitmq.config').with({
|
||||
'content' => /rabbitmq_stomp.*tcp_listeners, \[5679\].*ssl_listeners, \[5680\]/m,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'configuring ldap authentication' do
|
||||
let :params do
|
||||
{ :config_stomp => true,
|
||||
:ldap_auth => true,
|
||||
:ldap_server => 'ldap.example.com',
|
||||
:ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
|
||||
:ldap_use_ssl => false,
|
||||
:ldap_port => '389',
|
||||
:ldap_log => true
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
|
||||
|
||||
it 'should contain ldap parameters' do
|
||||
verify_contents(subject, 'rabbitmq.config',
|
||||
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
|
||||
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, anon},',
|
||||
' {servers, ["ldap.example.com"]},',
|
||||
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
|
||||
' {port, 389},', ' {log, true}'])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'configuring ldap authentication' do
|
||||
let :params do
|
||||
{ :config_stomp => false,
|
||||
:ldap_auth => true,
|
||||
:ldap_server => 'ldap.example.com',
|
||||
:ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
|
||||
:ldap_use_ssl => false,
|
||||
:ldap_port => '389',
|
||||
:ldap_log => true
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
|
||||
|
||||
it 'should contain ldap parameters' do
|
||||
verify_contents(subject, 'rabbitmq.config',
|
||||
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
|
||||
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, anon},',
|
||||
' {servers, ["ldap.example.com"]},',
|
||||
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
|
||||
' {port, 389},', ' {log, true}'])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'default_user and default_pass set' do
|
||||
let(:params) {{ :default_user => 'foo', :default_pass => 'bar' }}
|
||||
it 'should set default_user and default_pass to specified values' do
|
||||
should contain_file('rabbitmq.config').with({
|
||||
'content' => /default_user, <<"foo">>.*default_pass, <<"bar">>/m,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ssl options' do
|
||||
let(:params) {
|
||||
{ :ssl => true,
|
||||
:ssl_port => 3141,
|
||||
:ssl_cacert => '/path/to/cacert',
|
||||
:ssl_cert => '/path/to/cert',
|
||||
:ssl_key => '/path/to/key'
|
||||
} }
|
||||
|
||||
it 'should set ssl options to specified values' do
|
||||
should contain_file('rabbitmq.config').with_content(
|
||||
%r{ssl_listeners, \[3141\]}
|
||||
)
|
||||
should contain_file('rabbitmq.config').with_content(
|
||||
%r{ssl_options, \[\{cacertfile,"/path/to/cacert"}
|
||||
)
|
||||
should contain_file('rabbitmq.config').with_content(
|
||||
%r{certfile,"/path/to/cert"}
|
||||
)
|
||||
should contain_file('rabbitmq.config').with_content(
|
||||
%r{keyfile,"/path/to/key"}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ssl options with ssl_only' do
|
||||
let(:params) {
|
||||
{ :ssl => true,
|
||||
:ssl_only => true,
|
||||
:ssl_port => 3141,
|
||||
:ssl_cacert => '/path/to/cacert',
|
||||
:ssl_cert => '/path/to/cert',
|
||||
:ssl_key => '/path/to/key'
|
||||
} }
|
||||
|
||||
it 'should set ssl options to specified values' do
|
||||
should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[3141\]})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"})
|
||||
should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
|
||||
should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ssl admin options' do
|
||||
let(:params) {
|
||||
{ :ssl => true,
|
||||
:ssl_management_port => 3141,
|
||||
:ssl_cacert => '/path/to/cacert',
|
||||
:ssl_cert => '/path/to/cert',
|
||||
:ssl_key => '/path/to/key',
|
||||
:admin_enable => true
|
||||
} }
|
||||
|
||||
it 'should set rabbitmq_management ssl options to specified values' do
|
||||
should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{listener, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl, true\}})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[\{cacertfile, "/path/to/cacert"\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}\]\}})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin without ssl' do
|
||||
let(:params) {
|
||||
{ :ssl => false,
|
||||
:management_port => 3141,
|
||||
:admin_enable => true
|
||||
} }
|
||||
|
||||
it 'should set rabbitmq_management options to specified values' do
|
||||
should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{listener, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ssl admin options' do
|
||||
let(:params) {
|
||||
{ :ssl => true,
|
||||
:ssl_management_port => 3141,
|
||||
:ssl_cacert => '/path/to/cacert',
|
||||
:ssl_cert => '/path/to/cert',
|
||||
:ssl_key => '/path/to/key',
|
||||
:admin_enable => true
|
||||
} }
|
||||
|
||||
it 'should set rabbitmq_management ssl options to specified values' do
|
||||
should contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{listener, \[})
|
||||
should contain_file('rabbitmq.config').with_content(%r{port, 3141\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl, true\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[\{cacertfile, "/path/to/cacert"\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
|
||||
should contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}\]\}})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin without ssl' do
|
||||
let(:params) {
|
||||
{ :ssl => false,
|
||||
:management_port => 3141,
|
||||
:admin_enable => true
|
||||
} }
|
||||
|
||||
it 'should set rabbitmq_management options to specified values' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.with_content(/\{rabbitmq_management, \[/) \
|
||||
.with_content(/\{listener, \[/) \
|
||||
.with_content(/\{port, 3141\}/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'config_variables options' do
|
||||
let(:params) {{ :config_variables => {
|
||||
'hipe_compile' => true,
|
||||
'vm_memory_high_watermark' => 0.4,
|
||||
'frame_max' => 131072,
|
||||
'collect_statistics' => "none",
|
||||
'auth_mechanisms' => "['PLAIN', 'AMQPLAIN']",
|
||||
}}}
|
||||
it 'should set environment variables' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.with_content(/\{hipe_compile, true\}/) \
|
||||
.with_content(/\{vm_memory_high_watermark, 0.4\}/) \
|
||||
.with_content(/\{frame_max, 131072\}/) \
|
||||
.with_content(/\{collect_statistics, none\}/) \
|
||||
.with_content(/\{auth_mechanisms, \['PLAIN', 'AMQPLAIN'\]\}/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'config_kernel_variables options' do
|
||||
let(:params) {{ :config_kernel_variables => {
|
||||
'inet_dist_listen_min' => 9100,
|
||||
'inet_dist_listen_max' => 9105,
|
||||
}}}
|
||||
it 'should set config variables' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.with_content(/\{inet_dist_listen_min, 9100\}/) \
|
||||
.with_content(/\{inet_dist_listen_max, 9105\}/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'config_rabbitmq_management_variables' do
|
||||
let(:params) {{ :config_rabbitmq_management_variables => {
|
||||
'rates_mode' => 'none',
|
||||
}}}
|
||||
it 'should set config variables' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.with_content(/\{rates_mode, none\}/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'tcp_keepalive enabled' do
|
||||
let(:params) {{ :tcp_keepalive => true }}
|
||||
it 'should set tcp_listen_options keepalive true' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.with_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'tcp_keepalive disabled (default)' do
|
||||
it 'should not set tcp_listen_options' do
|
||||
should contain_file('rabbitmq.config') \
|
||||
.without_content(/\{tcp_listen_options, \[\{keepalive, true\}\]\},/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'non-bool tcp_keepalive parameter' do
|
||||
let :params do
|
||||
{ :tcp_keepalive => 'string' }
|
||||
end
|
||||
|
||||
it 'should raise an error' do
|
||||
expect {
|
||||
should contain_file('rabbitmq.config')
|
||||
}.to raise_error(Puppet::Error, /is not a boolean/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'delete_guest_user' do
|
||||
describe 'should do nothing by default' do
|
||||
it { should_not contain_rabbitmq_user('guest') }
|
||||
end
|
||||
|
||||
describe 'delete user when delete_guest_user set' do
|
||||
let(:params) {{ :delete_guest_user => true }}
|
||||
it 'removes the user' do
|
||||
should contain_rabbitmq_user('guest').with(
|
||||
'ensure' => 'absent',
|
||||
'provider' => 'rabbitmqctl'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
## rabbitmq::service
|
||||
##
|
||||
describe 'service with default params' do
|
||||
it { should contain_service('rabbitmq-server').with(
|
||||
'ensure' => 'running',
|
||||
'enable' => 'true',
|
||||
'hasstatus' => 'true',
|
||||
'hasrestart' => 'true'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'service with ensure stopped' do
|
||||
let :params do
|
||||
{ :service_ensure => 'stopped' }
|
||||
end
|
||||
|
||||
it { should contain_service('rabbitmq-server').with(
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'service with ensure neither running neither stopped' do
|
||||
let :params do
|
||||
{ :service_ensure => 'foo' }
|
||||
end
|
||||
|
||||
it 'should raise an error' do
|
||||
expect {
|
||||
should contain_service('rabbitmq-server').with(
|
||||
'ensure' => 'stopped' )
|
||||
}.to raise_error(Puppet::Error, /validate_re\(\): "foo" does not match "\^\(running\|stopped\)\$"/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'service with service_manage equal to false' do
|
||||
let :params do
|
||||
{ :service_manage => false }
|
||||
end
|
||||
|
||||
it { should_not contain_service('rabbitmq-server') }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
## rabbitmq::install
|
||||
##
|
||||
context "on RHEL" do
|
||||
let(:facts) {{ :osfamily => 'RedHat' }}
|
||||
let(:params) {{ :package_source => 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.3/rabbitmq-server-3.2.3-1.noarch.rpm' }}
|
||||
it 'installs the rabbitmq package' do
|
||||
should contain_package('rabbitmq-server').with(
|
||||
'ensure' => 'installed',
|
||||
'name' => 'rabbitmq-server',
|
||||
'provider' => 'rpm',
|
||||
'source' => 'http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.3/rabbitmq-server-3.2.3-1.noarch.rpm'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "on Debian" do
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian', :lsbdistcodename => 'precise' }}
|
||||
it 'installs the rabbitmq package' do
|
||||
should contain_package('rabbitmq-server').with(
|
||||
'ensure' => 'installed',
|
||||
'name' => 'rabbitmq-server',
|
||||
'provider' => 'apt'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "on Archlinux" do
|
||||
let(:facts) {{ :osfamily => 'Archlinux' }}
|
||||
it 'installs the rabbitmq package' do
|
||||
should contain_package('rabbitmq-server').with(
|
||||
'ensure' => 'installed',
|
||||
'name' => 'rabbitmq')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'repo management on Debian' do
|
||||
let(:facts) {{ :osfamily => 'Debian', :lsbdistid => 'Debian' }}
|
||||
|
||||
context 'with no pin' do
|
||||
let(:params) {{ :package_apt_pin => '' }}
|
||||
describe 'it sets up an apt::source' do
|
||||
|
||||
it { should contain_apt__source('rabbitmq').with(
|
||||
'location' => 'http://www.rabbitmq.com/debian/',
|
||||
'release' => 'testing',
|
||||
'repos' => 'main',
|
||||
'include_src' => false,
|
||||
'key' => 'F7B8CEA6056E8E56'
|
||||
) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with pin' do
|
||||
let(:params) {{ :package_apt_pin => '700' }}
|
||||
describe 'it sets up an apt::source and pin' do
|
||||
|
||||
it { should contain_apt__source('rabbitmq').with(
|
||||
'location' => 'http://www.rabbitmq.com/debian/',
|
||||
'release' => 'testing',
|
||||
'repos' => 'main',
|
||||
'include_src' => false,
|
||||
'key' => 'F7B8CEA6056E8E56'
|
||||
) }
|
||||
|
||||
it { should contain_apt__pin('rabbitmq').with(
|
||||
'packages' => 'rabbitmq-server',
|
||||
'priority' => '700'
|
||||
) }
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
['RedHat', 'SuSE'].each do |distro|
|
||||
describe "repo management on #{distro}" do
|
||||
describe 'imports the key' do
|
||||
let(:facts) {{ :osfamily => distro }}
|
||||
let(:params) {{ :package_gpg_key => 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc' }}
|
||||
|
||||
it { should contain_exec("rpm --import #{params[:package_gpg_key]}").with(
|
||||
'path' => ['/bin','/usr/bin','/sbin','/usr/sbin']
|
||||
) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
--format
|
||||
s
|
||||
--colour
|
||||
--loadby
|
||||
mtime
|
||||
--backtrace
|
|
@ -1 +0,0 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
|
@ -1,38 +0,0 @@
|
|||
require 'beaker-rspec'
|
||||
|
||||
UNSUPPORTED_PLATFORMS = []
|
||||
|
||||
unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
|
||||
if hosts.first.is_pe?
|
||||
install_pe
|
||||
else
|
||||
install_puppet
|
||||
end
|
||||
hosts.each do |host|
|
||||
on hosts, "mkdir -p #{host['distmoduledir']}"
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
# Project root
|
||||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
|
||||
# Readable test descriptions
|
||||
c.formatter = :documentation
|
||||
c.before :suite do
|
||||
hosts.each do |host|
|
||||
copy_module_to(host, :source => proj_root, :module_name => 'rabbitmq')
|
||||
|
||||
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
|
||||
shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] })
|
||||
if fact('osfamily') == 'Debian'
|
||||
shell('puppet module install puppetlabs-apt', { :acceptable_exit_codes => [0,1] })
|
||||
end
|
||||
shell('puppet module install nanliu-staging', { :acceptable_exit_codes => [0,1] })
|
||||
if fact('osfamily') == 'RedHat'
|
||||
shell('puppet module install garethr-erlang', { :acceptable_exit_codes => [0,1] })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'rabbitmq_erlang_cookie', :type => :fact do
|
||||
before(:each) { Facter.clear }
|
||||
|
||||
it 'works correctly' do
|
||||
Facter.fact(:osfamily).stubs(:value).returns('RedHat')
|
||||
File.stubs(:exists?).with('/var/lib/rabbitmq/.erlang.cookie').returns(true)
|
||||
File.stubs(:read).with('/var/lib/rabbitmq/.erlang.cookie').returns('THISISACOOKIE')
|
||||
Facter.fact(:rabbitmq_erlang_cookie).value.should == 'THISISACOOKIE'
|
||||
end
|
||||
|
||||
it 'fails if file doesnt exist' do
|
||||
Facter.fact(:osfamily).stubs(:value).returns('RedHat')
|
||||
File.stubs(:exists?).with('/var/lib/rabbitmq/.erlang.cookie').returns(false)
|
||||
Facter.fact(:rabbitmq_erlang_cookie).value.should == nil
|
||||
end
|
||||
|
||||
end
|
|
@ -1,65 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
provider_class = Puppet::Type.type(:rabbitmq_exchange).provider(:rabbitmqadmin)
|
||||
describe provider_class do
|
||||
before :each do
|
||||
@resource = Puppet::Type::Rabbitmq_exchange.new(
|
||||
{:name => 'amq.direct@/',
|
||||
:type => :topic}
|
||||
)
|
||||
@provider = provider_class.new(@resource)
|
||||
end
|
||||
|
||||
it 'should return instances' do
|
||||
provider_class.expects(:rabbitmqctl).with('list_vhosts').returns <<-EOT
|
||||
Listing vhosts ...
|
||||
/
|
||||
...done.
|
||||
EOT
|
||||
provider_class.expects(:rabbitmqctl).with('list_exchanges', '-p', '/', 'name', 'type').returns <<-EOT
|
||||
Listing exchanges ...
|
||||
direct
|
||||
amq.direct direct
|
||||
amq.fanout fanout
|
||||
amq.headers headers
|
||||
amq.match headers
|
||||
amq.rabbitmq.log topic
|
||||
amq.rabbitmq.trace topic
|
||||
amq.topic topic
|
||||
...done.
|
||||
EOT
|
||||
instances = provider_class.instances
|
||||
instances.size.should == 8
|
||||
end
|
||||
|
||||
it 'should call rabbitmqadmin to create' do
|
||||
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
|
||||
@provider.create
|
||||
end
|
||||
|
||||
it 'should call rabbitmqadmin to destroy' do
|
||||
@provider.expects(:rabbitmqadmin).with('delete', 'exchange', '--vhost=/', '--user=guest', '--password=guest', 'name=amq.direct', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
|
||||
@provider.destroy
|
||||
end
|
||||
|
||||
context 'specifying credentials' do
|
||||
before :each do
|
||||
@resource = Puppet::Type::Rabbitmq_exchange.new(
|
||||
{:name => 'amq.direct@/',
|
||||
:type => :topic,
|
||||
:user => 'colin',
|
||||
:password => 'secret',
|
||||
}
|
||||
)
|
||||
@provider = provider_class.new(@resource)
|
||||
end
|
||||
|
||||
it 'should call rabbitmqadmin to create' do
|
||||
@provider.expects(:rabbitmqadmin).with('declare', 'exchange', '--vhost=/', '--user=colin', '--password=secret', 'name=amq.direct', 'type=topic', '-c', '/etc/rabbitmq/rabbitmqadmin.conf')
|
||||
@provider.create
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
provider_class = Puppet::Type.type(:rabbitmq_plugin).provider(:rabbitmqplugins)
|
||||
describe provider_class do
|
||||
before :each do
|
||||
@resource = Puppet::Type::Rabbitmq_plugin.new(
|
||||
{:name => 'foo'}
|
||||
)
|
||||
@provider = provider_class.new(@resource)
|
||||
end
|
||||
it 'should match plugins' do
|
||||
@provider.expects(:rabbitmqplugins).with('list', '-E', '-m').returns("foo\n")
|
||||
@provider.exists?.should == 'foo'
|
||||
end
|
||||
it 'should call rabbitmqplugins to enable' do
|
||||
@provider.expects(:rabbitmqplugins).with('enable', 'foo')
|
||||
@provider.create
|
||||
end
|
||||
it 'should call rabbitmqplugins to disable' do
|
||||
@provider.expects(:rabbitmqplugins).with('disable', 'foo')
|
||||
@provider.destroy
|
||||
end
|
||||
end
|
|
@ -1,114 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
|
||||
describe Puppet::Type.type(:rabbitmq_policy).provider(:rabbitmqctl) do
|
||||
|
||||
let(:resource) do
|
||||
Puppet::Type.type(:rabbitmq_policy).new(
|
||||
:name => 'ha-all@/',
|
||||
:pattern => '.*',
|
||||
:definition => {
|
||||
'ha-mode' => 'all'
|
||||
},
|
||||
:provider => described_class.name
|
||||
)
|
||||
end
|
||||
|
||||
let(:provider) { resource.provider }
|
||||
|
||||
after(:each) do
|
||||
described_class.instance_variable_set(:@policies, nil)
|
||||
end
|
||||
|
||||
it 'should accept @ in policy name' do
|
||||
resource = Puppet::Type.type(:rabbitmq_policy).new(
|
||||
:name => 'ha@home@/',
|
||||
:pattern => '.*',
|
||||
:definition => {
|
||||
'ha-mode' => 'all'
|
||||
},
|
||||
:provider => described_class.name
|
||||
)
|
||||
provider = described_class.new(resource)
|
||||
provider.should_policy.should == 'ha@home'
|
||||
provider.should_vhost.should == '/'
|
||||
end
|
||||
|
||||
it 'should fail with invalid output from list' do
|
||||
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns 'foobar'
|
||||
expect { provider.exists? }.to raise_error(Puppet::Error, /cannot parse line from list_policies/)
|
||||
end
|
||||
|
||||
it 'should match policies from list (>=3.2.0)' do
|
||||
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns <<-EOT
|
||||
/ ha-all all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0
|
||||
/ test exchanges .* {"ha-mode":"all"} 0
|
||||
EOT
|
||||
provider.exists?.should == {
|
||||
:applyto => 'all',
|
||||
:pattern => '.*',
|
||||
:priority => '0',
|
||||
:definition => {
|
||||
'ha-mode' => 'all',
|
||||
'ha-sync-mode' => 'automatic'}
|
||||
}
|
||||
end
|
||||
|
||||
it 'should match policies from list (<3.2.0)' do
|
||||
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns <<-EOT
|
||||
/ ha-all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0
|
||||
/ test .* {"ha-mode":"all"} 0
|
||||
EOT
|
||||
provider.exists?.should == {
|
||||
:applyto => 'all',
|
||||
:pattern => '.*',
|
||||
:priority => '0',
|
||||
:definition => {
|
||||
'ha-mode' => 'all',
|
||||
'ha-sync-mode' => 'automatic'}
|
||||
}
|
||||
end
|
||||
|
||||
it 'should not match an empty list' do
|
||||
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns ''
|
||||
provider.exists?.should == nil
|
||||
end
|
||||
|
||||
it 'should destroy policy' do
|
||||
provider.expects(:rabbitmqctl).with('clear_policy', '-p', '/', 'ha-all')
|
||||
provider.destroy
|
||||
end
|
||||
|
||||
it 'should only call set_policy once (<3.2.0)' do
|
||||
provider.class.expects(:rabbitmq_version).returns '3.1.0'
|
||||
provider.resource[:priority] = '10'
|
||||
provider.resource[:applyto] = 'exchanges'
|
||||
provider.expects(:rabbitmqctl).with('set_policy',
|
||||
'-p', '/',
|
||||
'ha-all',
|
||||
'.*',
|
||||
'{"ha-mode":"all"}',
|
||||
'10').once
|
||||
provider.priority = '10'
|
||||
provider.applyto = 'exchanges'
|
||||
end
|
||||
|
||||
it 'should only call set_policy once (>=3.2.0)' do
|
||||
provider.class.expects(:rabbitmq_version).returns '3.2.0'
|
||||
provider.resource[:priority] = '10'
|
||||
provider.resource[:applyto] = 'exchanges'
|
||||
provider.expects(:rabbitmqctl).with('set_policy',
|
||||
'-p', '/',
|
||||
'--priority', '10',
|
||||
'--apply-to', 'exchanges',
|
||||
'ha-all',
|
||||
'.*',
|
||||
'{"ha-mode":"all"}').once
|
||||
provider.priority = '10'
|
||||
provider.applyto = 'exchanges'
|
||||
end
|
||||
end
|
|
@ -1,197 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
provider_class = Puppet::Type.type(:rabbitmq_user).provider(:rabbitmqctl)
|
||||
describe provider_class do
|
||||
before :each do
|
||||
@resource = Puppet::Type::Rabbitmq_user.new(
|
||||
{:name => 'foo', :password => 'bar'}
|
||||
)
|
||||
@provider = provider_class.new(@resource)
|
||||
end
|
||||
it 'should match user names' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo
|
||||
EOT
|
||||
@provider.exists?.should == 'foo'
|
||||
end
|
||||
it 'should match user names with 2.4.1 syntax' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo bar
|
||||
EOT
|
||||
@provider.exists?.should == 'foo bar'
|
||||
end
|
||||
it 'should not match if no users on system' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
EOT
|
||||
@provider.exists?.should be_nil
|
||||
end
|
||||
it 'should not match if no matching users on system' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
fooey
|
||||
EOT
|
||||
@provider.exists?.should be_nil
|
||||
end
|
||||
it 'should match user names from list' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one
|
||||
two three
|
||||
foo
|
||||
bar
|
||||
EOT
|
||||
@provider.exists?.should == 'foo'
|
||||
end
|
||||
it 'should create user and set password' do
|
||||
@resource[:password] = 'bar'
|
||||
@provider.expects(:rabbitmqctl).with('add_user', 'foo', 'bar')
|
||||
@provider.create
|
||||
end
|
||||
it 'should create user, set password and set to admin' do
|
||||
@resource[:password] = 'bar'
|
||||
@resource[:admin] = 'true'
|
||||
@provider.expects(:rabbitmqctl).with('add_user', 'foo', 'bar')
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo []
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ['administrator'])
|
||||
@provider.create
|
||||
end
|
||||
it 'should call rabbitmqctl to delete' do
|
||||
@provider.expects(:rabbitmqctl).with('delete_user', 'foo')
|
||||
@provider.destroy
|
||||
end
|
||||
it 'should be able to retrieve admin value' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo [administrator]
|
||||
EOT
|
||||
@provider.admin.should == :true
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one [administrator]
|
||||
foo []
|
||||
EOT
|
||||
@provider.admin.should == :false
|
||||
end
|
||||
it 'should fail if admin value is invalid' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo fail
|
||||
EOT
|
||||
expect { @provider.admin }.to raise_error(Puppet::Error, /Could not match line/)
|
||||
end
|
||||
it 'should be able to set admin value' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo []
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ['administrator'])
|
||||
@provider.admin=:true
|
||||
end
|
||||
it 'should not interfere with existing tags on the user when setting admin value' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo [bar, baz]
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ['bar','baz', 'administrator'].sort)
|
||||
@provider.admin=:true
|
||||
end
|
||||
it 'should be able to unset admin value' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo [administrator]
|
||||
guest [administrator]
|
||||
icinga []
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', [])
|
||||
@provider.admin=:false
|
||||
end
|
||||
it 'should not interfere with existing tags on the user when unsetting admin value' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo [administrator, bar, baz]
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ['bar','baz'].sort)
|
||||
@provider.admin=:false
|
||||
end
|
||||
|
||||
it 'should clear all tags on existing user' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one [administrator]
|
||||
foo [tag1,tag2]
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', [])
|
||||
@provider.tags=[]
|
||||
end
|
||||
|
||||
it 'should set multiple tags' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one [administrator]
|
||||
foo []
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ['tag1','tag2'])
|
||||
@provider.tags=['tag1','tag2']
|
||||
end
|
||||
|
||||
it 'should clear tags while keep admin tag' do
|
||||
@resource[:admin] = true
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one [administrator]
|
||||
foo [administrator, tag1, tag2]
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ["administrator"])
|
||||
@provider.tags=[]
|
||||
end
|
||||
|
||||
it 'should change tags while keep admin tag' do
|
||||
@resource[:admin] = true
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
one [administrator]
|
||||
foo [administrator, tag1, tag2]
|
||||
icinga [monitoring]
|
||||
kitchen []
|
||||
kitchen2 [abc, def, ghi]
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ["administrator","tag1","tag3","tag7"])
|
||||
@provider.tags=['tag1','tag7','tag3']
|
||||
end
|
||||
|
||||
it 'should create user with tags and without admin' do
|
||||
@resource[:tags] = [ "tag1", "tag2" ]
|
||||
@provider.expects(:rabbitmqctl).with('add_user', 'foo', 'bar')
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ["tag1","tag2"])
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').returns <<-EOT
|
||||
foo []
|
||||
EOT
|
||||
@provider.create
|
||||
end
|
||||
|
||||
it 'should create user with tags and with admin' do
|
||||
@resource[:tags] = [ "tag1", "tag2" ]
|
||||
@resource[:admin] = true
|
||||
@provider.expects(:rabbitmqctl).with('add_user', 'foo', 'bar')
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_users').twice.returns <<-EOT
|
||||
foo []
|
||||
EOT
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ["administrator"])
|
||||
@provider.expects(:rabbitmqctl).with('set_user_tags', 'foo', ["administrator","tag1","tag2"])
|
||||
@provider.create
|
||||
end
|
||||
|
||||
end
|
|
@ -1,93 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
describe 'Puppet::Type.type(:rabbitmq_user_permissions).provider(:rabbitmqctl)' do
|
||||
before :each do
|
||||
@provider_class = Puppet::Type.type(:rabbitmq_user_permissions).provider(:rabbitmqctl)
|
||||
@resource = Puppet::Type::Rabbitmq_user_permissions.new(
|
||||
{:name => 'foo@bar'}
|
||||
)
|
||||
@provider = @provider_class.new(@resource)
|
||||
end
|
||||
after :each do
|
||||
@provider_class.instance_variable_set(:@users, nil)
|
||||
end
|
||||
it 'should match user permissions from list' do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3
|
||||
EOT
|
||||
@provider.exists?.should == {:configure=>"1", :write=>"2", :read=>"3"}
|
||||
end
|
||||
it 'should match user permissions with empty columns' do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 3
|
||||
EOT
|
||||
@provider.exists?.should == {:configure=>"", :write=>"", :read=>"3"}
|
||||
end
|
||||
it 'should not match user permissions with more than 3 columns' do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3 4
|
||||
EOT
|
||||
expect { @provider.exists? }.to raise_error(Puppet::Error, /cannot parse line from list_user_permissions/)
|
||||
end
|
||||
it 'should not match an empty list' do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
EOT
|
||||
@provider.exists?.should == nil
|
||||
end
|
||||
it 'should create default permissions' do
|
||||
@provider.instance_variable_set(:@should_vhost, "bar")
|
||||
@provider.instance_variable_set(:@should_user, "foo")
|
||||
@provider.expects(:rabbitmqctl).with('set_permissions', '-p', 'bar', 'foo', "''", "''", "''")
|
||||
@provider.create
|
||||
end
|
||||
it 'should destroy permissions' do
|
||||
@provider.instance_variable_set(:@should_vhost, "bar")
|
||||
@provider.instance_variable_set(:@should_user, "foo")
|
||||
@provider.expects(:rabbitmqctl).with('clear_permissions', '-p', 'bar', 'foo')
|
||||
@provider.destroy
|
||||
end
|
||||
{:configure_permission => '1', :write_permission => '2', :read_permission => '3'}.each do |k,v|
|
||||
it "should be able to retrieve #{k}" do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3
|
||||
EOT
|
||||
@provider.send(k).should == v
|
||||
end
|
||||
end
|
||||
{:configure_permission => '1', :write_permission => '2', :read_permission => '3'}.each do |k,v|
|
||||
it "should be able to retrieve #{k} after exists has been called" do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3
|
||||
EOT
|
||||
@provider.exists?
|
||||
@provider.send(k).should == v
|
||||
end
|
||||
end
|
||||
{:configure_permission => ['foo', '2', '3'],
|
||||
:read_permission => ['1', '2', 'foo'],
|
||||
:write_permission => ['1', 'foo', '3']
|
||||
}.each do |perm, columns|
|
||||
it "should be able to sync #{perm}" do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3
|
||||
EOT
|
||||
@provider.resource[perm] = 'foo'
|
||||
@provider.expects(:rabbitmqctl).with('set_permissions', '-p', 'bar', 'foo', *columns)
|
||||
@provider.send("#{perm}=".to_sym, 'foo')
|
||||
end
|
||||
end
|
||||
it 'should only call set_permissions once' do
|
||||
@provider.class.expects(:rabbitmqctl).with('-q', 'list_user_permissions', 'foo').returns <<-EOT
|
||||
bar 1 2 3
|
||||
EOT
|
||||
@provider.resource[:configure_permission] = 'foo'
|
||||
@provider.resource[:read_permission] = 'foo'
|
||||
@provider.expects(:rabbitmqctl).with('set_permissions', '-p', 'bar', 'foo', 'foo', '2', 'foo').once
|
||||
@provider.configure_permission='foo'
|
||||
@provider.read_permission='foo'
|
||||
end
|
||||
end
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'mocha'
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
provider_class = Puppet::Type.type(:rabbitmq_vhost).provider(:rabbitmqctl)
|
||||
describe provider_class do
|
||||
before :each do
|
||||
@resource = Puppet::Type::Rabbitmq_vhost.new(
|
||||
{:name => 'foo'}
|
||||
)
|
||||
@provider = provider_class.new(@resource)
|
||||
end
|
||||
it 'should match vhost names' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
|
||||
Listing vhosts ...
|
||||
foo
|
||||
...done.
|
||||
EOT
|
||||
@provider.exists?.should == 'foo'
|
||||
end
|
||||
it 'should not match if no vhosts on system' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
|
||||
Listing vhosts ...
|
||||
...done.
|
||||
EOT
|
||||
@provider.exists?.should be_nil
|
||||
end
|
||||
it 'should not match if no matching vhosts on system' do
|
||||
@provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
|
||||
Listing vhosts ...
|
||||
fooey
|
||||
...done.
|
||||
EOT
|
||||
@provider.exists?.should be_nil
|
||||
end
|
||||
it 'should call rabbitmqctl to create' do
|
||||
@provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
|
||||
@provider.create
|
||||
end
|
||||
it 'should call rabbitmqctl to create' do
|
||||
@provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
|
||||
@provider.destroy
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/rabbitmq_exchange'
|
||||
describe Puppet::Type.type(:rabbitmq_exchange) do
|
||||
before :each do
|
||||
@exchange = Puppet::Type.type(:rabbitmq_exchange).new(
|
||||
:name => 'foo@bar',
|
||||
:type => :topic
|
||||
)
|
||||
end
|
||||
it 'should accept an exchange name' do
|
||||
@exchange[:name] = 'dan@pl'
|
||||
@exchange[:name].should == 'dan@pl'
|
||||
end
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_exchange).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
it 'should not allow whitespace in the name' do
|
||||
expect {
|
||||
@exchange[:name] = 'b r'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
it 'should not allow names without @' do
|
||||
expect {
|
||||
@exchange[:name] = 'b_r'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
|
||||
it 'should accept an exchange type' do
|
||||
@exchange[:type] = :direct
|
||||
@exchange[:type].should == :direct
|
||||
end
|
||||
it 'should require a type' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_exchange).new(:name => 'foo@bar')
|
||||
}.to raise_error(/.*must set type when creating exchange.*/)
|
||||
end
|
||||
it 'should not require a type when destroying' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_exchange).new(:name => 'foo@bar', :ensure => :absent)
|
||||
}.to_not raise_error
|
||||
end
|
||||
|
||||
it 'should accept a user' do
|
||||
@exchange[:user] = :root
|
||||
@exchange[:user].should == :root
|
||||
end
|
||||
|
||||
it 'should accept a password' do
|
||||
@exchange[:password] = :PaSsw0rD
|
||||
@exchange[:password].should == :PaSsw0rD
|
||||
end
|
||||
end
|
|
@ -1,91 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/rabbitmq_policy'
|
||||
|
||||
describe Puppet::Type.type(:rabbitmq_policy) do
|
||||
|
||||
before do
|
||||
@policy = Puppet::Type.type(:rabbitmq_policy).new(
|
||||
:name => 'ha-all@/',
|
||||
:pattern => '.*',
|
||||
:definition => {
|
||||
'ha-mode' => 'all'
|
||||
})
|
||||
end
|
||||
|
||||
it 'should accept a valid name' do
|
||||
@policy[:name] = 'ha-all@/'
|
||||
@policy[:name].should == 'ha-all@/'
|
||||
end
|
||||
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_policy).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
|
||||
it 'should fail when name does not have a @' do
|
||||
expect {
|
||||
@policy[:name] = 'ha-all'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
|
||||
it 'should accept a valid regex for pattern' do
|
||||
@policy[:pattern] = '.*?'
|
||||
@policy[:pattern].should == '.*?'
|
||||
end
|
||||
|
||||
it 'should accept an empty string for pattern' do
|
||||
@policy[:pattern] = ''
|
||||
@policy[:pattern].should == ''
|
||||
end
|
||||
|
||||
it 'should not accept invalid regex for pattern' do
|
||||
expect {
|
||||
@policy[:pattern] = '*'
|
||||
}.to raise_error(Puppet::Error, /Invalid regexp/)
|
||||
end
|
||||
|
||||
it 'should accept valid value for applyto' do
|
||||
[:all, :exchanges, :queues].each do |v|
|
||||
@policy[:applyto] = v
|
||||
@policy[:applyto].should == v
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not accept invalid value for applyto' do
|
||||
expect {
|
||||
@policy[:applyto] = 'me'
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
|
||||
it 'should accept a valid hash for definition' do
|
||||
definition = {'ha-mode' => 'all', 'ha-sync-mode' => 'automatic'}
|
||||
@policy[:definition] = definition
|
||||
@policy[:definition].should == definition
|
||||
end
|
||||
|
||||
it 'should not accept invalid hash for definition' do
|
||||
expect {
|
||||
@policy[:definition] = 'ha-mode'
|
||||
}.to raise_error(Puppet::Error, /Invalid definition/)
|
||||
|
||||
expect {
|
||||
@policy[:definition] = {'ha-mode' => ['a', 'b']}
|
||||
}.to raise_error(Puppet::Error, /Invalid definition/)
|
||||
end
|
||||
|
||||
it 'should accept valid value for priority' do
|
||||
[0, 10, '0', '10'].each do |v|
|
||||
@policy[:priority] = v
|
||||
@policy[:priority].should == v
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not accept invalid value for priority' do
|
||||
['-1', -1, '1.0', 1.0, 'abc', ''].each do |v|
|
||||
expect {
|
||||
@policy[:priority] = v
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/rabbitmq_user_permissions'
|
||||
describe Puppet::Type.type(:rabbitmq_user_permissions) do
|
||||
before :each do
|
||||
@perms = Puppet::Type.type(:rabbitmq_user_permissions).new(:name => 'foo@bar')
|
||||
end
|
||||
it 'should accept a valid hostname name' do
|
||||
@perms[:name] = 'dan@bar'
|
||||
@perms[:name].should == 'dan@bar'
|
||||
end
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_user_permissions).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
it 'should fail when names dont have a @' do
|
||||
expect {
|
||||
@perms[:name] = 'bar'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
[:configure_permission, :read_permission, :write_permission].each do |param|
|
||||
it 'should not default to anything' do
|
||||
@perms[param].should == nil
|
||||
end
|
||||
it "should accept a valid regex for #{param}" do
|
||||
@perms[param] = '.*?'
|
||||
@perms[param].should == '.*?'
|
||||
end
|
||||
it "should accept an empty string for #{param}" do
|
||||
@perms[param] = ''
|
||||
@perms[param].should == ''
|
||||
end
|
||||
it "should not accept invalid regex for #{param}" do
|
||||
expect {
|
||||
@perms[param] = '*'
|
||||
}.to raise_error(Puppet::Error, /Invalid regexp/)
|
||||
end
|
||||
end
|
||||
{:rabbitmq_vhost => 'dan@test', :rabbitmq_user => 'test@dan'}.each do |k,v|
|
||||
it "should autorequire #{k}" do
|
||||
if k == :rabbitmq_vhost
|
||||
vhost = Puppet::Type.type(k).new(:name => "test")
|
||||
else
|
||||
vhost = Puppet::Type.type(k).new(:name => "test", :password => 'pass')
|
||||
end
|
||||
perm = Puppet::Type.type(:rabbitmq_user_permissions).new(:name => v)
|
||||
config = Puppet::Resource::Catalog.new :testing do |conf|
|
||||
[vhost, perm].each { |resource| conf.add_resource resource }
|
||||
end
|
||||
rel = perm.autorequire[0]
|
||||
rel.source.ref.should == vhost.ref
|
||||
rel.target.ref.should == perm.ref
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/rabbitmq_user'
|
||||
describe Puppet::Type.type(:rabbitmq_user) do
|
||||
before :each do
|
||||
@user = Puppet::Type.type(:rabbitmq_user).new(:name => 'foo', :password => 'pass')
|
||||
end
|
||||
it 'should accept a user name' do
|
||||
@user[:name] = 'dan'
|
||||
@user[:name].should == 'dan'
|
||||
@user[:admin].should == :false
|
||||
end
|
||||
it 'should accept a password' do
|
||||
@user[:password] = 'foo'
|
||||
@user[:password].should == 'foo'
|
||||
end
|
||||
it 'should require a password' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_user).new(:name => 'foo')
|
||||
}.to raise_error(/must set password/)
|
||||
end
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_user).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
it 'should not allow whitespace in the name' do
|
||||
expect {
|
||||
@user[:name] = 'b r'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
[true, false, 'true', 'false'].each do |val|
|
||||
it "admin property should accept #{val}" do
|
||||
@user[:admin] = val
|
||||
@user[:admin].should == val.to_s.to_sym
|
||||
end
|
||||
end
|
||||
it 'should not accept non-boolean values for admin' do
|
||||
expect {
|
||||
@user[:admin] = 'yes'
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/rabbitmq_vhost'
|
||||
describe Puppet::Type.type(:rabbitmq_vhost) do
|
||||
before :each do
|
||||
@vhost = Puppet::Type.type(:rabbitmq_vhost).new(:name => 'foo')
|
||||
end
|
||||
it 'should accept a vhost name' do
|
||||
@vhost[:name] = 'dan'
|
||||
@vhost[:name].should == 'dan'
|
||||
end
|
||||
it 'should require a name' do
|
||||
expect {
|
||||
Puppet::Type.type(:rabbitmq_vhost).new({})
|
||||
}.to raise_error(Puppet::Error, 'Title or name must be provided')
|
||||
end
|
||||
it 'should not allow whitespace in the name' do
|
||||
expect {
|
||||
@vhost[:name] = 'b r'
|
||||
}.to raise_error(Puppet::Error, /Valid values match/)
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
Templates
|
||||
=========
|
||||
|
||||
Puppet supports templates and templating via ERB, which is part of the Ruby
|
||||
standard library and is used for many other projects including Ruby on Rails.
|
||||
Templates allow you to manage the content of template files, for example
|
||||
configuration files that cannot yet be managed as a Puppet type. Learn more at
|
||||
http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Templating
|
||||
|
||||
You can use templates like this:
|
||||
|
||||
class myclass {
|
||||
package { mypackage: ensure => latest }
|
||||
service { myservice: ensure => running }
|
||||
file { "/etc/myfile":
|
||||
content => template("mymodule/myfile.erb")
|
||||
}
|
||||
}
|
||||
|
||||
The templates are searched for in:
|
||||
|
||||
$templatedir/mymodule/myfile.erb
|
||||
$modulepath/mymodule/templates/myfile.erb
|
|
@ -1,5 +0,0 @@
|
|||
<%- @environment_variables.keys.sort.each do |key| -%>
|
||||
<%- if @environment_variables[key] != 'UNSET' -%>
|
||||
<%= key %>=<%= @environment_variables[key] %>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
|
@ -1,79 +0,0 @@
|
|||
% This file managed by Puppet
|
||||
% Template Path: <%= @module_name %>/templates/rabbitmq.config
|
||||
[
|
||||
{rabbit, [
|
||||
<% if @ldap_auth -%>
|
||||
{auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},
|
||||
<% end -%>
|
||||
<% if @config_cluster -%>
|
||||
{cluster_nodes, {[<%= @cluster_nodes.map { |n| "\'rabbit@#{n}\'" }.join(', ') %>], <%= @cluster_node_type %>}},
|
||||
{cluster_partition_handling, <%= @cluster_partition_handling %>},
|
||||
<% end -%>
|
||||
<%- if @tcp_keepalive -%>
|
||||
{tcp_listen_options, [{keepalive, true}]},
|
||||
<%- end -%>
|
||||
<%- if @ssl_only -%>
|
||||
{tcp_listeners, []},
|
||||
<%- end -%>
|
||||
<%- if @ssl -%>
|
||||
{ssl_listeners, [<%= @ssl_port %>]},
|
||||
{ssl_options, [<%- if @ssl_cacert != 'UNSET' -%>{cacertfile,"<%= @ssl_cacert %>"},<%- end -%>
|
||||
{certfile,"<%= @ssl_cert %>"},
|
||||
{keyfile,"<%= @ssl_key %>"},
|
||||
{verify,<%= @ssl_verify %>},
|
||||
{fail_if_no_peer_cert,<%= @ssl_fail_if_no_peer_cert %>}]},
|
||||
<%- end -%>
|
||||
<% if @config_variables -%>
|
||||
<%- @config_variables.keys.sort.each do |key| -%>
|
||||
{<%= key %>, <%= @config_variables[key] %>},
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
{default_user, <<"<%= @default_user %>">>},
|
||||
{default_pass, <<"<%= @default_pass %>">>}
|
||||
]}<% if @config_kernel_variables -%>,
|
||||
{kernel, [
|
||||
<%= @config_kernel_variables.sort.map{|k,v| "{#{k}, #{v}}"}.join(",\n ") %>
|
||||
]}
|
||||
<%- end -%>
|
||||
<% if @config_rabbitmq_management_variables -%>,
|
||||
{rabbitmq_management, [
|
||||
<%= @config_rabbitmq_management_variables.sort.map{|k,v| "{#{k}, #{v}}"}.join(",\n ") %>
|
||||
]}
|
||||
<%- end -%>
|
||||
<%- if @admin_enable -%>,
|
||||
{rabbitmq_management, [
|
||||
{listener, [
|
||||
<%- if @ssl -%>
|
||||
{port, <%= @ssl_management_port %>},
|
||||
{ssl, true},
|
||||
{ssl_opts, [<%- if @ssl_cacert != 'UNSET' -%>{cacertfile, "<%= @ssl_cacert %>"},<%- end -%>
|
||||
{certfile, "<%= @ssl_cert %>"},
|
||||
{keyfile, "<%= @ssl_key %>"}]}
|
||||
<%- else -%>
|
||||
{port, <%= @management_port %>}
|
||||
<%- end -%>
|
||||
]}
|
||||
]}
|
||||
<%- end -%>
|
||||
<% if @config_stomp -%>,
|
||||
% Configure the Stomp Plugin listening port
|
||||
{rabbitmq_stomp, [
|
||||
{tcp_listeners, [<%= @stomp_port %>]}
|
||||
<%- if @ssl && @ssl_stomp_port -%>,
|
||||
{ssl_listeners, [<%= @ssl_stomp_port %>]}
|
||||
<%- end -%>
|
||||
]}
|
||||
<% end -%>
|
||||
<%- if @ldap_auth -%>,
|
||||
% Configure the LDAP authentication plugin
|
||||
{rabbitmq_auth_backend_ldap, [
|
||||
{other_bind, anon},
|
||||
{servers, ["<%= @ldap_server %>"]},
|
||||
{user_dn_pattern, "<%= @ldap_user_dn_pattern %>"},
|
||||
{use_ssl, <%= @ldap_use_ssl %>},
|
||||
{port, <%= @ldap_port %>},
|
||||
{log, <%= @ldap_log %>}
|
||||
]}
|
||||
<%- end -%>
|
||||
].
|
||||
% EOF
|
|
@ -1,8 +0,0 @@
|
|||
[default]
|
||||
<% if @ssl -%>
|
||||
ssl = True
|
||||
port = <%= @ssl_management_port %>
|
||||
<% else -%>
|
||||
ssl = False
|
||||
port = <%= @management_port %>
|
||||
<% end -%>
|
|
@ -1,5 +0,0 @@
|
|||
# install first the garethr-erlang module. See README.md
|
||||
include 'erlang'
|
||||
|
||||
class { 'erlang': epel_enable => true}
|
||||
Class['erlang'] -> Class['rabbitmq']
|
|
@ -1,21 +0,0 @@
|
|||
class { 'rabbitmq::repo::apt':
|
||||
pin => '900',
|
||||
}->
|
||||
class { 'rabbitmq::server':
|
||||
delete_guest_user => true,
|
||||
# version => '2.4.1',
|
||||
}->
|
||||
rabbitmq_user { 'dan':
|
||||
admin => true,
|
||||
password => 'pass',
|
||||
provider => 'rabbitmqctl',
|
||||
}->
|
||||
rabbitmq_vhost { 'myhost':
|
||||
provider => 'rabbitmqctl',
|
||||
}
|
||||
rabbitmq_user_permissions { 'dan@myhost':
|
||||
configure_permission => '.*',
|
||||
read_permission => '.*',
|
||||
write_permission => '.*',
|
||||
provider => 'rabbitmqctl',
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
rabbitmq_user { 'blah7':
|
||||
password => 'foo',
|
||||
}
|
||||
rabbitmq_vhost { 'test5': }
|
||||
rabbitmq_user_permissions { 'blah7@test5':
|
||||
configure_permission => 'config2',
|
||||
read_permission => 'ready',
|
||||
#write_permission => 'ready',
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
class { 'rabbitmq::server':
|
||||
config_stomp => true,
|
||||
}
|
||||
|
||||
$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ]
|
||||
|
||||
rabbitmq_plugin { $rabbitmq_plugins:
|
||||
ensure => present,
|
||||
require => Class['rabbitmq::server'],
|
||||
provider => 'rabbitmqplugins',
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
# requires pupetlabs-apt
|
||||
include rabbitmq::repo::apt
|
|
@ -1,5 +0,0 @@
|
|||
class { 'rabbitmq::server':
|
||||
port => '5672',
|
||||
delete_guest_user => true,
|
||||
version => 'latest',
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
class { 'rabbitmq::service': }
|
|
@ -1,16 +0,0 @@
|
|||
node default {
|
||||
|
||||
$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ]
|
||||
|
||||
class { 'rabbitmq::server':
|
||||
config => '[ {rabbit_stomp, [{tcp_listeners, [1234]} ]} ].',
|
||||
}
|
||||
|
||||
# Required for MCollective
|
||||
rabbitmq_plugin { $rabbitmq_plugins:
|
||||
ensure => present,
|
||||
require => Class['rabbitmq::server'],
|
||||
provider => 'rabbitmqplugins',
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
rabbitmq_user { ['blah2', 'blah3', 'blah4']:
|
||||
password => 'phoey!',
|
||||
#provider => 'rabbitmqctl',
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
rabbitmq_vhost { ['fooey', 'blah']: }
|
|
@ -51,8 +51,8 @@ describe manifest do
|
|||
node_ip_address = Noop.puppet_function 'get_network_role_property', 'mgmt/messaging', 'ipaddr'
|
||||
listener = "[{port, 15672}, {ip,\"#{node_ip_address}\"}]"
|
||||
should contain_class('rabbitmq').with_config_variables(/#{collect_statistics_interval}/)
|
||||
should contain_class('rabbitmq').with_config_rabbitmq_management_variables(/#{rates_mode}/)
|
||||
should contain_class('rabbitmq').with_config_rabbitmq_management_variables(/#{listener}/)
|
||||
should contain_class('rabbitmq').with_config_management_variables(/#{rates_mode}/)
|
||||
should contain_class('rabbitmq').with_config_management_variables(/#{listener}/)
|
||||
end
|
||||
|
||||
# Partial LP#1493520
|
||||
|
|
|
@ -25,6 +25,7 @@ ntp
|
|||
openssl
|
||||
openstacklib
|
||||
postgresql
|
||||
rabbitmq
|
||||
rsync
|
||||
sahara
|
||||
ssh
|
||||
|
|
Loading…
Reference in New Issue