Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/data/common.yaml b/data/common.yaml
new file mode 100644
index 0000000..ce9887f
--- /dev/null
+++ b/data/common.yaml
@@ -0,0 +1,99 @@
+---
+rabbitmq::admin_enable: true
+rabbitmq::management_enable: false
+rabbitmq::use_config_file_for_plugins: false
+rabbitmq::cluster_node_type: 'disc'
+rabbitmq::cluster_nodes: []
+rabbitmq::config: 'rabbitmq/rabbitmq.config.erb'
+rabbitmq::config_cluster: false
+rabbitmq::config_path: '/etc/rabbitmq/rabbitmq.config'
+rabbitmq::config_ranch: true
+rabbitmq::config_stomp: false
+rabbitmq::config_shovel: false
+rabbitmq::config_shovel_statics: {}
+rabbitmq::default_user: 'guest'
+rabbitmq::default_pass: 'guest'
+rabbitmq::delete_guest_user: false
+rabbitmq::env_config: 'rabbitmq/rabbitmq-env.conf.erb'
+rabbitmq::env_config_path: '/etc/rabbitmq/rabbitmq-env.conf'
+rabbitmq::erlang_cookie: ~
+rabbitmq::interface: ~
+rabbitmq::management_ip_address: ~
+rabbitmq::management_port: 15672
+rabbitmq::management_ssl: true
+rabbitmq::management_hostname: ~
+rabbitmq::node_ip_address: ~
+rabbitmq::package_apt_pin: ~
+rabbitmq::package_ensure: 'installed'
+rabbitmq::package_gpg_key: ~
+rabbitmq::package_name: 'rabbitmq'
+rabbitmq::package_source: ~
+rabbitmq::package_provider: ~
+rabbitmq::repos_ensure: false
+rabbitmq::manage_python: true
+rabbitmq::python_package: 'python'
+rabbitmq::rabbitmq_user: 'rabbitmq'
+rabbitmq::rabbitmq_group: 'rabbitmq'
+rabbitmq::rabbitmq_home: '/var/lib/rabbitmq'
+rabbitmq::port: 5672
+rabbitmq::tcp_keepalive: false
+rabbitmq::tcp_backlog: 128
+rabbitmq::tcp_sndbuf: ~
+rabbitmq::tcp_recbuf: ~
+rabbitmq::heartbeat: ~
+rabbitmq::service_ensure: 'running'
+rabbitmq::service_manage: true
+rabbitmq::service_name: 'rabbitmq'
+rabbitmq::ssl: false
+rabbitmq::ssl_only: false
+rabbitmq::ssl_cacert: ~
+rabbitmq::ssl_cert: ~
+rabbitmq::ssl_key: ~
+rabbitmq::ssl_depth: ~
+rabbitmq::ssl_cert_password: ~
+rabbitmq::ssl_port: 5671
+rabbitmq::ssl_interface: ~
+rabbitmq::ssl_management_port: 15671
+rabbitmq::ssl_stomp_port: 6164
+rabbitmq::ssl_verify: 'verify_none'
+rabbitmq::ssl_fail_if_no_peer_cert: false
+rabbitmq::ssl_management_verify: 'verify_none'
+rabbitmq::ssl_management_fail_if_no_peer_cert: false
+rabbitmq::ssl_versions: ~
+rabbitmq::ssl_secure_renegotiate: true
+rabbitmq::ssl_reuse_sessions: true
+rabbitmq::ssl_honor_cipher_order: true
+rabbitmq::ssl_dhfile: ~
+rabbitmq::ssl_ciphers: []
+rabbitmq::stomp_ensure: false
+rabbitmq::ldap_auth: false
+rabbitmq::ldap_server: 'ldap'
+rabbitmq::ldap_user_dn_pattern: ~
+rabbitmq::ldap_other_bind: 'anon'
+rabbitmq::ldap_use_ssl: false
+rabbitmq::ldap_port: 389
+rabbitmq::ldap_log: false
+rabbitmq::ldap_config_variables: {}
+rabbitmq::stomp_port: 6163
+rabbitmq::stomp_ssl_only: false
+rabbitmq::wipe_db_on_cookie_change: false
+rabbitmq::cluster_partition_handling: 'ignore'
+rabbitmq::file_limit: 16384
+rabbitmq::environment_variables:
+ 'LC_ALL': 'en_US.UTF-8'
+rabbitmq::config_variables: {}
+rabbitmq::config_kernel_variables: {}
+rabbitmq::config_management_variables: {}
+rabbitmq::config_additional_variables: {}
+rabbitmq::auth_backends: ~
+rabbitmq::key_content: ~
+rabbitmq::collect_statistics_interval: ~
+rabbitmq::ipv6: false
+rabbitmq::inetrc_config: 'rabbitmq/inetrc.erb'
+rabbitmq::inetrc_config_path: '/etc/rabbitmq/inetrc'
+rabbitmq::ssl_erl_dist: false
+rabbitmq::rabbitmqadmin_package: ~
+rabbitmq::archive_options: []
+rabbitmq::loopback_users:
+ - 'guest'
+rabbitmq::service_restart: true
diff --git a/data/family/Archlinux.yaml b/data/family/Archlinux.yaml
new file mode 100644
index 0000000..62f41ff
--- /dev/null
+++ b/data/family/Archlinux.yaml
@@ -0,0 +1,3 @@
+---
+rabbitmq::python_package: 'python2'
+rabbitmq::rabbitmqadmin_package: 'rabbitmqadmin'
diff --git a/data/family/Debian.yaml b/data/family/Debian.yaml
new file mode 100644
index 0000000..77d8d0f
--- /dev/null
+++ b/data/family/Debian.yaml
@@ -0,0 +1,4 @@
+---
+rabbitmq::package_name: 'rabbitmq-server'
+rabbitmq::service_name: 'rabbitmq-server'
+rabbitmq::package_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
diff --git a/data/family/FreeBSD.yaml b/data/family/FreeBSD.yaml
new file mode 100644
index 0000000..e7929d2
--- /dev/null
+++ b/data/family/FreeBSD.yaml
@@ -0,0 +1,6 @@
+---
+rabbitmq::python_package: 'python2'
+rabbitmq::rabbitmq_home: '/var/db/rabbitmq'
+rabbitmq::config_path: '/usr/local/etc/rabbitmq/rabbitmq.config'
+rabbitmq::env_config_path: '/usr/loca/etc/rabbitmq/rabbitmq-env.conf'
+rabbitmq::inetrc_config_path: '/usr/local/etc/rabbitmq/inetrc'
diff --git a/data/family/OpenBSD.yaml b/data/family/OpenBSD.yaml
new file mode 100644
index 0000000..a99a506
--- /dev/null
+++ b/data/family/OpenBSD.yaml
@@ -0,0 +1,5 @@
+---
+rabbitmq::python_package: 'python2'
+rabbitmq::rabbitmq_user: '_rabbitmq'
+rabbitmq::rabbitmq_group: '_rabbitmq'
+rabbitmq::rabbitmq_home: '/var/rabbitmq'
diff --git a/data/family/RedHat.yaml b/data/family/RedHat.yaml
new file mode 100644
index 0000000..521319d
--- /dev/null
+++ b/data/family/RedHat.yaml
@@ -0,0 +1,4 @@
+---
+rabbitmq::package_name: 'rabbitmq-server'
+rabbitmq::service_name: 'rabbitmq-server'
+rabbitmq::package_gpg_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc'
diff --git a/data/family/Suse.yaml b/data/family/Suse.yaml
new file mode 100644
index 0000000..3cc0a40
--- /dev/null
+++ b/data/family/Suse.yaml
@@ -0,0 +1,5 @@
+---
+rabbitmq::package_name:
+ - 'rabbitmq-server'
+ - 'rabbitmq-server-plugins'
+rabbitmq::service_name: 'rabbitmq-server'
diff --git a/hiera.yaml b/hiera.yaml
new file mode 100644
index 0000000..e6158dd
--- /dev/null
+++ b/hiera.yaml
@@ -0,0 +1,16 @@
+---
+version: 5
+
+defaults:
+ datadir: 'data'
+ data_hash: 'yaml_data'
+
+hierarchy:
+ - name: 'Major Version'
+ path: "os/%{facts.os.name}-%{facts.os.release.major}.yaml"
+ - name: 'Distribution Name'
+ path: "os/%{facts.os.name}.yaml"
+ - name: 'Operating System Family'
+ path: "family/%{facts.os.family}.yaml"
+ - name: 'Common'
+ path: 'common.yaml'
diff --git a/manifests/init.pp b/manifests/init.pp
index cd47379..de98f98 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,487 +1,490 @@
#
# @summary A module to manage RabbitMQ
#
# @example Basic usage
# include rabbitmq
#
# @example rabbitmq class
# class { 'rabbitmq':
# service_manage => false,
# port => '5672',
# delete_guest_user => true,
# }
#
# @example Offline installation from local mirror:
# class { 'rabbitmq':
# key_content => template('openstack/rabbit.pub.key'),
# package_gpg_key => '/tmp/rabbit.pub.key',
# }
#
# @example Use external package key source for any (apt/rpm) package provider:
# class { 'rabbitmq':
# package_gpg_key => 'http://www.some_site.some_domain/some_key.pub.key',
# }
#
# @example To use RabbitMQ Environment Variables, use the parameters `environment_variables` e.g.:
# class { 'rabbitmq':
# port => '5672',
# environment_variables => {
# 'NODENAME' => 'node01',
# 'SERVICENAME' => 'RabbitMQ'
# }
# }
#
# @example Change RabbitMQ Config Variables in rabbitmq.config:
# class { 'rabbitmq':
# port => '5672',
# config_variables => {
# 'hipe_compile' => true,
# 'frame_max' => 131072,
# 'log_levels' => "[{connection, info}]"
# }
# }
#
# @example Change Erlang Kernel Config Variables in rabbitmq.config
# class { 'rabbitmq':
# port => '5672',
# config_kernel_variables => {
# 'inet_dist_listen_min' => 9100,
# 'inet_dist_listen_max' => 9105,
# }
# }
#
# @example Change Management Plugin Config Variables in rabbitmq.config
# class { 'rabbitmq':
# config_management_variables => {
# 'rates_mode' => 'basic',
# }
# }
#
# @example Change Additional Config Variables in rabbitmq.config
# class { 'rabbitmq':
# config_additional_variables => {
# 'autocluster' => '[{consul_service, "rabbit"},{cluster_name, "rabbit"}]',
# 'foo' => '[{bar, "baz"}]'
# }
# }
#
# This will result in the following config appended to the config file:
# {autocluster, [{consul_service, "rabbit"},{cluster_name, "rabbit"}]},
# {foo, [{bar, "baz"}]}
# (This is required for the [autocluster plugin](https://github.com/aweber/rabbitmq-autocluster)
#
# @example Use RabbitMQ clustering facilities
# class { 'rabbitmq':
# config_cluster => true,
# cluster_nodes => ['rabbit1', 'rabbit2'],
# cluster_node_type => 'ram',
# erlang_cookie => 'A_SECRET_COOKIE_STRING',
# wipe_db_on_cookie_change => true,
# }
#
# @param admin_enable
# If enabled sets up the management interface/plugin for RabbitMQ.
# This also install the rabbitmqadmin command line tool.
# @param management_enable
# If enabled sets up the management interface/plugin for RabbitMQ.
# NOTE: This does not install the rabbitmqadmin command line tool.
# @param use_config_file_for_plugins
# If enabled the /etc/rabbitmq/enabled_plugins config file is created,
# replacing the use of the rabbitmqplugins provider to enable plugins.
# @param auth_backends
# An array specifying authorization/authentication backend to use. Single quotes should be placed around array entries,
# ex. `['{foo, baz}', 'baz']` Defaults to [rabbit_auth_backend_internal], and if using LDAP defaults to [rabbit_auth_backend_internal,
# rabbit_auth_backend_ldap].
# @param cluster_node_type
# Choose between disc and ram nodes.
# @param cluster_nodes
# An array of nodes for clustering.
# @param cluster_partition_handling
# Value to set for `cluster_partition_handling` RabbitMQ configuration variable.
# @param collect_statistics_interval
# Set the collect_statistics_interval in rabbitmq.config
# @param config
# The file to use as the rabbitmq.config template.
# @param config_additional_variables
# Additional config variables in rabbitmq.config
# @param config_cluster
# Enable or disable clustering support.
# @param config_kernel_variables
# Hash of Erlang kernel configuration variables to set (see [Variables Configurable in rabbitmq.config](#variables-configurable-in-rabbitmq.config)).
# @param config_path
# The path to write the RabbitMQ configuration file to.
# @param config_ranch
# When true, suppress config directives needed for older (<3.6) RabbitMQ versions.
# @param config_management_variables
# Hash of configuration variables for the [Management Plugin](https://www.rabbitmq.com/management.html).
# @param config_stomp
# Enable or disable stomp.
# @param config_shovel
# Enable or disable shovel.
# @param config_shovel_statics
# Hash of static shovel configurations
# @param config_variables
# To set config variables in rabbitmq.config
# @param default_user
# Username to set for the `default_user` in rabbitmq.config.
# @param default_pass
# Password to set for the `default_user` in rabbitmq.config.
# @param delete_guest_user
# Controls whether default guest user is deleted.
# @param env_config
# The template file to use for rabbitmq_env.config.
# @param env_config_path
# The path to write the rabbitmq_env.config file to.
# @param environment_variables
# RabbitMQ Environment Variables in rabbitmq_env.config
# @param 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. If you run Pacemaker and you don't want to use RabbitMQ buildin cluster, you can set config_cluster
# to 'False' and set 'erlang_cookie'.
# @param file_limit
# Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with `$::osfamily == 'Debian'` or `$::osfamily == 'RedHat'`.
# @param heartbeat
# Set the heartbeat timeout interval, default is unset which uses the builtin server defaults of 60 seconds. Setting this
# @param inetrc_config
# Template to use for the inetrc config
# @param inetrc_config_path
# Path of the file to push the inetrc config to.
# @param ipv6
# Whether to listen on ipv6
# @param interface
# Interface to bind to (sets tcp_listeners parameter). By default, bind to all interfaces
# to `0` will disable heartbeats.
# @param 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.
# @param ldap_auth
# Set to true to enable LDAP auth.
# @param ldap_server
# LDAP server to use for auth.
# @param ldap_user_dn_pattern
# User DN pattern for LDAP auth.
# @param ldap_other_bind
# How to bind to the LDAP server. Defaults to 'anon'.
# @param ldap_config_variables
# Hash of other LDAP config variables.
# @param ldap_use_ssl
# Set to true to use SSL for the LDAP server.
# @param ldap_port
# Numeric port for LDAP server.
# @param ldap_log
# Set to true to log LDAP auth.
# @param manage_python
# If enabled, on platforms that don't provide a Python 2 package by default, ensure that the python package is
# installed (for rabbitmqadmin). This will only apply if `admin_enable` and `service_manage` are set.
# @param management_hostname
# The hostname for the RabbitMQ management interface.
# @param management_port
# The port for the RabbitMQ management interface.
# @param management_ip_address
# Allows you to set the IP for management interface to bind to separately. Set to 127.0.0.1 to bind to
# localhost only, or 0.0.0.0 to bind to all interfaces.
# @param management_ssl
# Enable/Disable SSL for the management port. Has an effect only if ssl => true.
# @param node_ip_address
# Allows you to set the IP for RabbitMQ service to bind to. Set to 127.0.0.1 to bind to localhost only, or 0.0.0.0
# to bind to all interfaces.
# @param package_apt_pin
# Whether to pin the package to a particular source
# @param package_ensure
# Determines the ensure state of the package. Set to installed by default, but could be changed to latest.
# @param 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 https://www.rabbitmq.com/rabbitmq-release-signing-key.asc for RedHat OS Family and
# https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey for Debian OS Family by default. Note, that `key_content`, if specified, would
# override this parameter for Debian OS family.
# @param package_name
# Name(s) of the package(s) to install
# @param port
# The RabbitMQ port.
+# @param python_package
+# Name of the package required by rabbitmqadmin.
# @param repos_ensure
# Ensure that a repo with the official (and newer) RabbitMQ package is configured, along with its signing key.
# Defaults to false (use system packages). This does not ensure that soft dependencies (like EPEL on RHEL systems) are present.
# It also does not solve the erlang dependency. See https://www.rabbitmq.com/which-erlang.html for a good breakdown of the
# different ways of handling the erlang deps. See also https://github.com/voxpupuli/puppet-rabbitmq/issues/788
# @param service_ensure
# The state of the service.
# @param service_manage
# Determines if the service is managed.
# @param service_name
# The name of the service to manage.
# @param service_restart
# Default defined in param.pp. Whether to restart the service on config change.
# @param ssl
# Configures the service for using SSL.
# @param ssl_cacert
# CA cert path to use for SSL.
# @param ssl_cert
# Cert to use for SSL.
# @param ssl_cert_password
# Password used when generating CSR.
# @param ssl_depth
# SSL verification depth.
# @param ssl_dhfile
# Use this dhparam file [example: generate with `openssl dhparam -out /etc/rabbitmq/ssl/dhparam.pem 2048`
# @param ssl_erl_dist
# Whether to use the erlang package's SSL (relies on the ssl_erl_path fact)
# @param ssl_honor_cipher_order
# Force use of server cipher order
# @param ssl_interface
# Interface for SSL listener to bind to
# @param ssl_key
# Key to use for SSL.
# @param ssl_only
# Configures the service to only use SSL. No cleartext TCP listeners will be created. Requires that ssl => true and
# port => undef
# @param ssl_management_port
# SSL management port.
# @param ssl_port
# SSL port for RabbitMQ
# @param ssl_reuse_sessions
# Reuse ssl sessions
# @param ssl_secure_renegotiate
# Use ssl secure renegotiate
# @param ssl_stomp_port
# SSL stomp port.
# @param ssl_verify
# rabbitmq.config SSL verify setting.
# @param ssl_fail_if_no_peer_cert
# rabbitmq.config `fail_if_no_peer_cert` setting.
# @param ssl_management_verify
# rabbitmq.config SSL verify setting for rabbitmq_management.
# @param ssl_versions
# Choose which SSL versions to enable. Example: `['tlsv1.2', 'tlsv1.1']` Note
# that it is recommended to disable `sslv3 and `tlsv1` to prevent against
# POODLE and BEAST attacks. Please see the
# [RabbitMQ SSL](https://www.rabbitmq.com/ssl.html) documentation for more information.
# @param ssl_ciphers
# Support only a given list of SSL ciphers. Example: `['dhe_rsa,aes_256_cbc,sha','dhe_dss,aes_256_cbc,sha', 'ecdhe_rsa,aes_256_cbc,sha']`. Supported ciphers in your install can be listed with: rabbitmqctl eval 'ssl:cipher_suites().'
# Functionality can be tested with cipherscan or similar tool: https://github.com/jvehent/cipherscan.git
# @param stomp_port
# The port to use for Stomp.
# @param stomp_ssl_only
# Configures STOMP to only use SSL. No cleartext STOMP TCP listeners will be created. Requires setting ssl_stomp_port also.
# @param stomp_ensure
# Enable to install the stomp plugin.
# @param tcp_backlog
# The size of the backlog on TCP connections.
# @param tcp_keepalive
# Enable TCP connection keepalive for RabbitMQ service.
# @param tcp_recbuf
# Corresponds to recbuf in RabbitMQ `tcp_listen_options`
# @param tcp_sndbuf
# Integer, corresponds to sndbuf in RabbitMQ `tcp_listen_options`
# @param wipe_db_on_cookie_change
# Boolean to determine if we should DESTROY AND DELETE the RabbitMQ database.
# @param rabbitmq_user
# OS dependent The system user the rabbitmq daemon runs as.
# @param rabbitmq_group
# OS dependent The system group the rabbitmq daemon runs as.
# @param rabbitmq_home
# OS dependent The home directory of the rabbitmq deamon.
# @param rabbitmqadmin_package
# OS dependent If undef: install rabbitmqadmin via archive, otherwise via package
# @param archive_options
# Extra options to Archive resource to download rabbitmqadmin file
# @param loopback_users
# This option configures a list of users to allow access via the loopback interfaces
#
class rabbitmq(
- Boolean $admin_enable = $rabbitmq::params::admin_enable,
- Boolean $management_enable = $rabbitmq::params::management_enable,
- Boolean $use_config_file_for_plugins = $rabbitmq::params::use_config_file_for_plugins,
- Enum['ram', 'disk', 'disc'] $cluster_node_type = $rabbitmq::params::cluster_node_type,
- Array $cluster_nodes = $rabbitmq::params::cluster_nodes,
- String $config = $rabbitmq::params::config,
- Boolean $config_cluster = $rabbitmq::params::config_cluster,
- Stdlib::Absolutepath $config_path = $rabbitmq::params::config_path,
- Boolean $config_ranch = $rabbitmq::params::config_ranch,
- Boolean $config_stomp = $rabbitmq::params::config_stomp,
- Boolean $config_shovel = $rabbitmq::params::config_shovel,
- Hash $config_shovel_statics = $rabbitmq::params::config_shovel_statics,
- String $default_user = $rabbitmq::params::default_user,
- String $default_pass = $rabbitmq::params::default_pass,
- Boolean $delete_guest_user = $rabbitmq::params::delete_guest_user,
- String $env_config = $rabbitmq::params::env_config,
- Stdlib::Absolutepath $env_config_path = $rabbitmq::params::env_config_path,
+ Boolean $admin_enable = true,
+ Boolean $management_enable = false,
+ Boolean $use_config_file_for_plugins = false,
+ Enum['ram', 'disk', 'disc'] $cluster_node_type = 'disc',
+ Array $cluster_nodes = [],
+ String $config = 'rabbitmq/rabbitmq.config.erb',
+ Boolean $config_cluster = false,
+ Stdlib::Absolutepath $config_path = '/etc/rabbitmq/rabbitmq.config',
+ Boolean $config_ranch = true,
+ Boolean $config_stomp = false,
+ Boolean $config_shovel = false,
+ Hash $config_shovel_statics = {},
+ String $default_user = 'guest',
+ String $default_pass = 'guest',
+ Boolean $delete_guest_user = false,
+ String $env_config = 'rabbitmq/rabbitmq-env.conf.erb',
+ Stdlib::Absolutepath $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf',
Optional[String] $erlang_cookie = undef,
Optional[String] $interface = undef,
Optional[String] $management_ip_address = undef,
- Integer[1, 65535] $management_port = $rabbitmq::params::management_port,
- Boolean $management_ssl = $rabbitmq::params::management_ssl,
+ Integer[1, 65535] $management_port = 15672,
+ Boolean $management_ssl = true,
Optional[String] $management_hostname = undef,
Optional[String] $node_ip_address = undef,
Optional[Variant[Numeric, String]] $package_apt_pin = undef,
- String $package_ensure = $rabbitmq::params::package_ensure,
- Optional[String] $package_gpg_key = $rabbitmq::params::package_gpg_key,
- Variant[String, Array] $package_name = $rabbitmq::params::package_name,
+ String $package_ensure = 'installed',
+ Optional[String] $package_gpg_key = undef,
+ Variant[String, Array] $package_name = 'rabbitmq',
Optional[String] $package_source = undef,
Optional[String] $package_provider = undef,
- Boolean $repos_ensure = $rabbitmq::params::repos_ensure,
- Boolean $manage_python = $rabbitmq::params::manage_python,
- String $rabbitmq_user = $rabbitmq::params::rabbitmq_user,
- String $rabbitmq_group = $rabbitmq::params::rabbitmq_group,
- Stdlib::Absolutepath $rabbitmq_home = $rabbitmq::params::rabbitmq_home,
- Integer $port = $rabbitmq::params::port,
- Boolean $tcp_keepalive = $rabbitmq::params::tcp_keepalive,
- Integer $tcp_backlog = $rabbitmq::params::tcp_backlog,
+ Boolean $repos_ensure = false,
+ Boolean $manage_python = true,
+ String $python_package = 'python',
+ String $rabbitmq_user = 'rabbitmq',
+ String $rabbitmq_group = 'rabbitmq',
+ Stdlib::Absolutepath $rabbitmq_home = '/var/lib/rabbitmq',
+ Integer $port = 5672,
+ Boolean $tcp_keepalive = false,
+ Integer $tcp_backlog = 128,
Optional[Integer] $tcp_sndbuf = undef,
Optional[Integer] $tcp_recbuf = undef,
Optional[Integer] $heartbeat = undef,
- Enum['running', 'stopped'] $service_ensure = $rabbitmq::params::service_ensure,
- Boolean $service_manage = $rabbitmq::params::service_manage,
- String $service_name = $rabbitmq::params::service_name,
- Boolean $ssl = $rabbitmq::params::ssl,
- Boolean $ssl_only = $rabbitmq::params::ssl_only,
+ Enum['running', 'stopped'] $service_ensure = 'running',
+ Boolean $service_manage = true,
+ String $service_name = 'rabbitmq',
+ Boolean $ssl = false,
+ Boolean $ssl_only = false,
Optional[Stdlib::Absolutepath] $ssl_cacert = undef,
Optional[Stdlib::Absolutepath] $ssl_cert = undef,
Optional[Stdlib::Absolutepath] $ssl_key = undef,
Optional[Integer] $ssl_depth = undef,
Optional[String] $ssl_cert_password = undef,
- Integer[1, 65535] $ssl_port = $rabbitmq::params::ssl_port,
+ Integer[1, 65535] $ssl_port = 5671,
Optional[String] $ssl_interface = undef,
- Integer[1, 65535] $ssl_management_port = $rabbitmq::params::ssl_management_port,
- Integer[1, 65535] $ssl_stomp_port = $rabbitmq::params::ssl_stomp_port,
- Enum['verify_none','verify_peer'] $ssl_verify = $rabbitmq::params::ssl_verify,
- Boolean $ssl_fail_if_no_peer_cert = $rabbitmq::params::ssl_fail_if_no_peer_cert,
- Enum['verify_none','verify_peer'] $ssl_management_verify = $rabbitmq::params::ssl_management_verify,
- Boolean $ssl_management_fail_if_no_peer_cert = $rabbitmq::params::ssl_management_fail_if_no_peer_cert,
+ Integer[1, 65535] $ssl_management_port = 15671,
+ Integer[1, 65535] $ssl_stomp_port = 6164,
+ Enum['verify_none','verify_peer'] $ssl_verify = 'verify_none',
+ Boolean $ssl_fail_if_no_peer_cert = false,
+ Enum['verify_none','verify_peer'] $ssl_management_verify = 'verify_none',
+ Boolean $ssl_management_fail_if_no_peer_cert = false,
Optional[Array] $ssl_versions = undef,
- Boolean $ssl_secure_renegotiate = $rabbitmq::params::ssl_secure_renegotiate,
- Boolean $ssl_reuse_sessions = $rabbitmq::params::ssl_reuse_sessions,
- Boolean $ssl_honor_cipher_order = $rabbitmq::params::ssl_honor_cipher_order,
+ Boolean $ssl_secure_renegotiate = true,
+ Boolean $ssl_reuse_sessions = true,
+ Boolean $ssl_honor_cipher_order = true,
Optional[Stdlib::Absolutepath] $ssl_dhfile = undef,
- Array $ssl_ciphers = $rabbitmq::params::ssl_ciphers,
- Boolean $stomp_ensure = $rabbitmq::params::stomp_ensure,
- Boolean $ldap_auth = $rabbitmq::params::ldap_auth,
- String $ldap_server = $rabbitmq::params::ldap_server,
- Optional[String] $ldap_user_dn_pattern = $rabbitmq::params::ldap_user_dn_pattern,
- String $ldap_other_bind = $rabbitmq::params::ldap_other_bind,
- Boolean $ldap_use_ssl = $rabbitmq::params::ldap_use_ssl,
- Integer[1, 65535] $ldap_port = $rabbitmq::params::ldap_port,
- Boolean $ldap_log = $rabbitmq::params::ldap_log,
- Hash $ldap_config_variables = $rabbitmq::params::ldap_config_variables,
- Integer[1, 65535] $stomp_port = $rabbitmq::params::stomp_port,
- Boolean $stomp_ssl_only = $rabbitmq::params::stomp_ssl_only,
- Boolean $wipe_db_on_cookie_change = $rabbitmq::params::wipe_db_on_cookie_change,
- String $cluster_partition_handling = $rabbitmq::params::cluster_partition_handling,
- Variant[Integer[-1],Enum['unlimited'],Pattern[/^(infinity|\d+(:(infinity|\d+))?)$/]] $file_limit = $rabbitmq::params::file_limit,
- Hash $environment_variables = $rabbitmq::params::environment_variables,
- Hash $config_variables = $rabbitmq::params::config_variables,
- Hash $config_kernel_variables = $rabbitmq::params::config_kernel_variables,
- Hash $config_management_variables = $rabbitmq::params::config_management_variables,
- Hash $config_additional_variables = $rabbitmq::params::config_additional_variables,
+ Array $ssl_ciphers = [],
+ Boolean $stomp_ensure = false,
+ Boolean $ldap_auth = false,
+ String $ldap_server = 'ldap',
+ Optional[String] $ldap_user_dn_pattern = undef,
+ String $ldap_other_bind = 'anon',
+ Boolean $ldap_use_ssl = false,
+ Integer[1, 65535] $ldap_port = 389,
+ Boolean $ldap_log = false,
+ Hash $ldap_config_variables = {},
+ Integer[1, 65535] $stomp_port = 6163,
+ Boolean $stomp_ssl_only = false,
+ Boolean $wipe_db_on_cookie_change = false,
+ String $cluster_partition_handling = 'ignore',
+ Variant[Integer[-1],Enum['unlimited'],Pattern[/^(infinity|\d+(:(infinity|\d+))?)$/]] $file_limit = 16384,
+ Hash $environment_variables = { 'LC_ALL' => 'en_US.UTF-8' },
+ Hash $config_variables = {},
+ Hash $config_kernel_variables = {},
+ Hash $config_management_variables = {},
+ Hash $config_additional_variables = {},
Optional[Array] $auth_backends = undef,
Optional[String] $key_content = undef,
Optional[Integer] $collect_statistics_interval = undef,
- Boolean $ipv6 = $rabbitmq::params::ipv6,
- String $inetrc_config = $rabbitmq::params::inetrc_config,
- Stdlib::Absolutepath $inetrc_config_path = $rabbitmq::params::inetrc_config_path,
- Boolean $ssl_erl_dist = $rabbitmq::params::ssl_erl_dist,
- Optional[String] $rabbitmqadmin_package = $rabbitmq::params::rabbitmqadmin_package,
- Array $archive_options = $rabbitmq::params::archive_options,
- Array $loopback_users = $rabbitmq::params::loopback_users,
- Boolean $service_restart = $rabbitmq::params::service_restart,
-) inherits rabbitmq::params {
+ Boolean $ipv6 = false,
+ String $inetrc_config = 'rabbitmq/inetrc.erb',
+ Stdlib::Absolutepath $inetrc_config_path = '/etc/rabbitmq/inetrc',
+ Boolean $ssl_erl_dist = false,
+ Optional[String] $rabbitmqadmin_package = undef,
+ Array $archive_options = [],
+ Array $loopback_users = ['guest'],
+ Boolean $service_restart = true,
+) {
if $ssl_only and ! $ssl {
fail('$ssl_only => true requires that $ssl => true')
}
if $config_stomp and $stomp_ssl_only and ! $ssl_stomp_port {
fail('$stomp_ssl_only requires that $ssl_stomp_port be set')
}
if $ssl_versions {
unless $ssl {
fail('$ssl_versions requires that $ssl => true')
}
}
if $repos_ensure {
case $facts['os']['family'] {
'RedHat': {
contain rabbitmq::repo::rhel
Class['rabbitmq::repo::rhel'] -> Class['rabbitmq::install']
}
'Debian': {
contain rabbitmq::repo::apt
Class['rabbitmq::repo::apt'] -> Class['rabbitmq::install']
}
default: {
}
}
}
contain rabbitmq::install
contain rabbitmq::config
contain rabbitmq::service
contain rabbitmq::management
unless $use_config_file_for_plugins {
# NOTE(hjensas): condition on $service_manage to keep current behaviour.
# The condition is likely not required because installiton of rabbitmqadmin
# is no longer handled here.
# TODO: Remove the condition on $service_manage
if ($management_enable or $admin_enable) and $service_manage {
rabbitmq_plugin { 'rabbitmq_management':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}
if ($stomp_ensure) {
rabbitmq_plugin { 'rabbitmq_stomp':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}
if ($ldap_auth) {
rabbitmq_plugin { 'rabbitmq_auth_backend_ldap':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}
if ($config_shovel) {
rabbitmq_plugin { 'rabbitmq_shovel':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
if ($management_enable or $admin_enable) {
rabbitmq_plugin { 'rabbitmq_shovel_management':
ensure => present,
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}
}
}
if $admin_enable and $service_manage {
include 'rabbitmq::install::rabbitmqadmin'
Class['rabbitmq::service'] -> Class['rabbitmq::install::rabbitmqadmin']
Class['rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |>
}
if ($service_restart) {
Class['rabbitmq::config'] ~> Class['rabbitmq::service']
}
Class['rabbitmq::install']
-> Class['rabbitmq::config']
-> Class['rabbitmq::service']
-> Class['rabbitmq::management']
# Make sure the various providers have their requirements in place.
Class['rabbitmq::install'] -> Rabbitmq_plugin<| |>
}
diff --git a/manifests/install/rabbitmqadmin.pp b/manifests/install/rabbitmqadmin.pp
index acd6728..d923a6f 100644
--- a/manifests/install/rabbitmqadmin.pp
+++ b/manifests/install/rabbitmqadmin.pp
@@ -1,72 +1,72 @@
# Install rabbitmq admin
#
# @api private
class rabbitmq::install::rabbitmqadmin {
if $rabbitmq::rabbitmqadmin_package {
package{'rabbitmqadmin':
ensure => 'present',
name => $rabbitmq::rabbitmqadmin_package,
}
} else {
- $python_package = $rabbitmq::params::python_package
+ $python_package = $rabbitmq::python_package
# Some systems (e.g., Ubuntu 16.04) don't ship Python 2 by default
if $rabbitmq::manage_python {
ensure_packages([$python_package])
$rabbitmqadmin_require = [Archive['rabbitmqadmin'], Package[$python_package]]
} else {
$rabbitmqadmin_require = Archive['rabbitmqadmin']
}
if($rabbitmq::ssl and $rabbitmq::management_ssl) {
$management_port = $rabbitmq::ssl_management_port
$protocol = 'https'
} else {
$management_port = $rabbitmq::management_port
$protocol = 'http'
}
$default_user = $rabbitmq::default_user
$default_pass = $rabbitmq::default_pass
$management_ip_address = $rabbitmq::management_ip_address
$archive_options = $rabbitmq::archive_options
if !($management_ip_address) {
# Pull from localhost if we don't have an explicit bind address
$curl_prefix = ''
$sanitized_ip = '127.0.0.1'
} elsif $management_ip_address =~ Stdlib::Compat::Ipv6 {
$curl_prefix = "--noproxy ${management_ip_address} -g -6"
$sanitized_ip = join(enclose_ipv6(any2array($management_ip_address)), ',')
} else {
$curl_prefix = "--noproxy ${management_ip_address}"
$sanitized_ip = $management_ip_address
}
if !($rabbitmq::use_config_file_for_plugins) {
$rabbitmqadmin_archive_require = [Class['rabbitmq::service'], Rabbitmq_plugin['rabbitmq_management']]
} else {
$rabbitmqadmin_archive_require = [Class['rabbitmq::service'], File['enabled_plugins']]
}
archive { 'rabbitmqadmin':
path => "${rabbitmq::rabbitmq_home}/rabbitmqadmin",
source => "${protocol}://${sanitized_ip}:${management_port}/cli/rabbitmqadmin",
username => $default_user,
password => $default_pass,
allow_insecure => true,
download_options => $archive_options,
cleanup => false,
require => $rabbitmqadmin_archive_require,
}
file { '/usr/local/bin/rabbitmqadmin':
owner => 'root',
group => '0',
source => "${rabbitmq::rabbitmq_home}/rabbitmqadmin",
mode => '0755',
require => $rabbitmqadmin_require,
}
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
deleted file mode 100644
index 3ef5b81..0000000
--- a/manifests/params.pp
+++ /dev/null
@@ -1,166 +0,0 @@
-# @summary OS Specific parameters and other settings
-#
-# @api private
-class rabbitmq::params {
-
- case $facts['os']['family'] {
- 'Archlinux': {
- $manage_python = true
- $python_package = 'python2'
- $package_ensure = 'installed'
- $package_name = 'rabbitmq'
- $service_name = 'rabbitmq'
- $rabbitmq_user = 'rabbitmq'
- $rabbitmq_group = 'rabbitmq'
- $rabbitmq_home = '/var/lib/rabbitmq'
- $package_gpg_key = undef
- $rabbitmqadmin_package = 'rabbitmqadmin'
- $config_path = '/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/etc/rabbitmq/inetrc'
- }
- 'Debian': {
- $manage_python = true
- $python_package = 'python'
- $package_ensure = 'installed'
- $package_name = 'rabbitmq-server'
- $service_name = 'rabbitmq-server'
- $rabbitmq_user = 'rabbitmq'
- $rabbitmq_group = 'rabbitmq'
- $rabbitmq_home = '/var/lib/rabbitmq'
- $package_gpg_key = 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
- $rabbitmqadmin_package = undef
- $config_path = '/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/etc/rabbitmq/inetrc'
- }
- 'OpenBSD': {
- $manage_python = true
- $python_package = 'python2'
- $package_ensure = 'installed'
- $package_name = 'rabbitmq'
- $service_name = 'rabbitmq'
- $rabbitmq_user = '_rabbitmq'
- $rabbitmq_group = '_rabbitmq'
- $rabbitmq_home = '/var/rabbitmq'
- $package_gpg_key = undef
- $rabbitmqadmin_package = undef
- $config_path = '/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/etc/rabbitmq/inetrc'
- }
- 'FreeBSD': {
- $manage_python = true
- $python_package = 'python2'
- $package_ensure = 'installed'
- $package_name = 'rabbitmq'
- $service_name = 'rabbitmq'
- $rabbitmq_user = 'rabbitmq'
- $rabbitmq_group = 'rabbitmq'
- $rabbitmq_home = '/var/db/rabbitmq'
- $package_gpg_key = undef
- $rabbitmqadmin_package = undef
- $config_path = '/usr/local/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/usr/local/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/usr/local/etc/rabbitmq/inetrc'
- }
- 'RedHat': {
- $manage_python = true
- $python_package = 'python'
- $package_ensure = 'installed'
- $package_name = 'rabbitmq-server'
- $service_name = 'rabbitmq-server'
- $rabbitmq_user = 'rabbitmq'
- $rabbitmq_group = 'rabbitmq'
- $rabbitmq_home = '/var/lib/rabbitmq'
- $package_gpg_key = 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc'
- $rabbitmqadmin_package = undef
- $config_path = '/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/etc/rabbitmq/inetrc'
- }
- 'SUSE': {
- $manage_python = true
- $python_package = 'python'
- $package_ensure = 'installed'
- $package_name = ['rabbitmq-server', 'rabbitmq-server-plugins']
- $service_name = 'rabbitmq-server'
- $rabbitmq_user = 'rabbitmq'
- $rabbitmq_group = 'rabbitmq'
- $rabbitmq_home = '/var/lib/rabbitmq'
- $package_gpg_key = undef
- $rabbitmqadmin_package = undef
- $config_path = '/etc/rabbitmq/rabbitmq.config'
- $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf'
- $inetrc_config_path = '/etc/rabbitmq/inetrc'
- }
- default: {
- fail("The ${module_name} module is not supported on an ${facts['os']['family']} based system.")
- }
- }
-
- #install
- $admin_enable = true
- $management_enable = false
- $use_config_file_for_plugins = false
- $management_port = 15672
- $management_ssl = true
- $repos_ensure = false
- $service_ensure = 'running'
- $service_manage = true
- #config
- $cluster_node_type = 'disc'
- $cluster_nodes = []
- $config = 'rabbitmq/rabbitmq.config.erb'
- $config_cluster = false
- $config_ranch = true
- $config_stomp = false
- $config_shovel = false
- $config_shovel_statics = {}
- $default_user = 'guest'
- $default_pass = 'guest'
- $delete_guest_user = false
- $env_config = 'rabbitmq/rabbitmq-env.conf.erb'
- $port = 5672
- $tcp_keepalive = false
- $tcp_backlog = 128
- $ssl = false
- $ssl_ciphers = []
- $ssl_erl_dist = false
- $ssl_fail_if_no_peer_cert = false
- $ssl_honor_cipher_order = true
- $ssl_management_port = 15671
- $ssl_only = false
- $ssl_port = 5671
- $ssl_reuse_sessions = true
- $ssl_secure_renegotiate = true
- $ssl_stomp_port = 6164
- $ssl_verify = 'verify_none'
- $ssl_versions = undef
- $ssl_management_verify = 'verify_none'
- $ssl_management_fail_if_no_peer_cert = false
- $stomp_ensure = false
- $stomp_port = 6163
- $stomp_ssl_only = false
- $ldap_auth = false
- $ldap_server = 'ldap'
- $ldap_user_dn_pattern = undef
- $ldap_other_bind = 'anon'
- $ldap_use_ssl = false
- $ldap_port = 389
- $ldap_log = false
- $ldap_config_variables = {}
- $wipe_db_on_cookie_change = false
- $cluster_partition_handling = 'ignore'
- $environment_variables = { 'LC_ALL' => 'en_US.UTF-8' }
- $config_variables = {}
- $config_kernel_variables = {}
- $config_management_variables = {}
- $config_additional_variables = {}
- $file_limit = 16384
- $ipv6 = false
- $inetrc_config = 'rabbitmq/inetrc.erb'
- $archive_options = []
- $loopback_users = ['guest']
- $service_restart = true
-}
diff --git a/manifests/server.pp b/manifests/server.pp
index 4cb33b5..5186225 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -1,79 +1,79 @@
# @summary Backwards compatibility layer to support including `rabbitmq::server` directly.
#
# This module manages the installation and config of the rabbitmq server. It is used as backward compability layer for modules which
# require rabbitmq::server instead of rabbitmq class.
#
# @param port
# Port that rabbitmq server should listen to
# @param delete_guest_user
# Whether or not to delete the default user
# @param package_name
# Name of rabbitmq package
# @param service_name
# Name of rabbitmq service
# @param service_ensure
# Desired ensure state for service
# @param service_manage
# Determines if the service is managed
# @param config_stomp
# Enable or disable stomp
# @param stomp_port
# Port stomp should be listening on
# @param node_ip_address
# IP address for rabbitmq to bind to
# @param config
# Contents of config file
# @param env_config
# Contents of env-config file
# @param config_cluster
# Whether to configure a RabbitMQ cluster
# @param cluster_nodes
# Which nodes to cluster with (including the current one)
# @param cluster_node_type
# Type of cluster node (disc/disk or ram)
# @param erlang_cookie
# Erlang cookie, must be the same for all nodes in a cluster
# @param 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.
#
class rabbitmq::server(
- Integer $port = $rabbitmq::params::port,
- Boolean $delete_guest_user = $rabbitmq::params::delete_guest_user,
- Variant[String, Array] $package_name = $rabbitmq::params::package_name,
- String $service_name = $rabbitmq::params::service_name,
- Enum['running', 'stopped'] $service_ensure = $rabbitmq::params::service_ensure,
- Boolean $service_manage = $rabbitmq::params::service_manage,
- Boolean $config_stomp = $rabbitmq::params::config_stomp,
- Integer[1, 65535] $stomp_port = $rabbitmq::params::stomp_port,
- Boolean $config_cluster = $rabbitmq::params::config_cluster,
- Array $cluster_nodes = $rabbitmq::params::cluster_nodes,
- Enum['ram', 'disk', 'disc'] $cluster_node_type = $rabbitmq::params::cluster_node_type,
- Optional[String] $node_ip_address = $rabbitmq::params::node_ip_address,
- String $config = $rabbitmq::params::config,
- String $env_config = $rabbitmq::params::env_config,
- Optional[String] $erlang_cookie = $rabbitmq::params::erlang_cookie,
- Boolean $wipe_db_on_cookie_change = $rabbitmq::params::wipe_db_on_cookie_change,
-) inherits rabbitmq::params {
+ Integer $port = $rabbitmq::port,
+ Boolean $delete_guest_user = $rabbitmq::delete_guest_user,
+ Variant[String, Array] $package_name = $rabbitmq::package_name,
+ String $service_name = $rabbitmq::service_name,
+ Enum['running', 'stopped'] $service_ensure = $rabbitmq::service_ensure,
+ Boolean $service_manage = $rabbitmq::service_manage,
+ Boolean $config_stomp = $rabbitmq::config_stomp,
+ Integer[1, 65535] $stomp_port = $rabbitmq::stomp_port,
+ Boolean $config_cluster = $rabbitmq::config_cluster,
+ Array $cluster_nodes = $rabbitmq::cluster_nodes,
+ Enum['ram', 'disk', 'disc'] $cluster_node_type = $rabbitmq::cluster_node_type,
+ Optional[String] $node_ip_address = $rabbitmq::node_ip_address,
+ String $config = $rabbitmq::config,
+ String $env_config = $rabbitmq::env_config,
+ Optional[String] $erlang_cookie = $rabbitmq::erlang_cookie,
+ Boolean $wipe_db_on_cookie_change = $rabbitmq::wipe_db_on_cookie_change,
+) {
class { 'rabbitmq':
port => $port,
delete_guest_user => $delete_guest_user,
package_name => $package_name,
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,
}
contain rabbitmq
}
diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb
index ea27b4f..a8dfa66 100644
--- a/spec/classes/rabbitmq_spec.rb
+++ b/spec/classes/rabbitmq_spec.rb
@@ -1,1571 +1,1559 @@
require 'spec_helper'
describe 'rabbitmq' do
- context 'on unsupported distributions' do
- let(:facts) do
- {
- os: { family: 'Unsupported' }
- }
- end
-
- it 'we fail' do
- expect { catalogue }.to raise_error(Puppet::Error, %r{not supported on an Unsupported})
- end
- end
-
on_supported_os.each do |os, facts|
context "on #{os}" do
systemd_facts = os_specific_facts(facts)
facts = facts.merge(systemd_facts)
let :facts do
facts
end
name = case facts[:osfamily]
when 'Archlinux', 'OpenBSD', 'FreeBSD'
'rabbitmq'
else
'rabbitmq-server'
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('rabbitmq::install') }
it { is_expected.to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
it { is_expected.to contain_class('rabbitmq::service') }
it { is_expected.to contain_package(name).with_ensure('installed').with_name(name) }
if facts[:os]['family'] == 'Suse'
it { is_expected.to contain_package('rabbitmq-server-plugins') }
end
context 'with default params' do
it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
it { is_expected.not_to contain_apt__source('rabbitmq') }
it { is_expected.not_to contain_class('rabbitmq::repo::rhel') }
it { is_expected.not_to contain_yumrepo('rabbitmq') }
end
context 'with service_restart => false' do
let(:params) { { service_restart: false } }
it { is_expected.not_to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
end
context 'with repos_ensure => true' do
let(:params) { { repos_ensure: true } }
if facts[:os]['family'] == 'Debian'
it 'includes rabbitmq::repo::apt' do
is_expected.to contain_class('rabbitmq::repo::apt').
with_key_source('https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey').
with_key_content(nil)
end
it 'adds a repo with default values' do
is_expected.to contain_apt__source('rabbitmq').
with_ensure('present').
with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}").
with_release(nil).
with_repos('main')
end
else
it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
it { is_expected.not_to contain_apt__souce('rabbitmq') }
end
if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_class('rabbitmq::repo::rhel') }
it 'the repo should be present, and contain the expected values' do
is_expected.to contain_yumrepo('rabbitmq').
with_ensure('present').
with_baseurl(%r{https://packagecloud.io/rabbitmq/rabbitmq-server/el/\d+/\$basearch$}).
with_gpgkey('https://www.rabbitmq.com/rabbitmq-release-signing-key.asc')
end
else
it { is_expected.not_to contain_class('rabbitmq::repo::rhel') }
it { is_expected.not_to contain_yumrepo('rabbitmq') }
end
end
context 'with no pin', if: facts[:os]['family'] == 'Debian' do
let(:params) { { repos_ensure: true, package_apt_pin: '' } }
if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180
let(:expected_key_apt_source_key_content) { 'nil' }
else
let(:expected_key_apt_source_key_content) { ':undef' }
end
describe 'it sets up an apt::source' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => "{\"id\"=>\"8C695B0219AFDEB04A058ED8F4E789204D206F89\", \"source\"=>\"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey\", \"content\"=>#{expected_key_apt_source_key_content}}"
)
}
end
end
context 'with pin', if: facts[:os]['family'] == 'Debian' do
let(:params) { { repos_ensure: true, package_apt_pin: '700' } }
if Puppet.version =~ %r{^6} # https://tickets.puppetlabs.com/browse/PUP-9112 and https://tickets.puppetlabs.com/browse/PUP-9180
let(:expected_key_apt_source_key_content) { 'nil' }
else
let(:expected_key_apt_source_key_content) { ':undef' }
end
describe 'it sets up an apt::source and pin' do
it {
is_expected.to contain_apt__source('rabbitmq').with(
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
'repos' => 'main',
'key' => "{\"id\"=>\"8C695B0219AFDEB04A058ED8F4E789204D206F89\", \"source\"=>\"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey\", \"content\"=>#{expected_key_apt_source_key_content}}"
)
}
it {
is_expected.to contain_apt__pin('rabbitmq').with(
'packages' => '*',
'priority' => '700',
'origin' => 'packagecloud.io'
)
}
end
end
['infinity', -1, 1234].each do |value|
context "with file_limit => '#{value}'" do
let(:params) { { file_limit: value } }
if facts[:os]['family'] == 'RedHat'
it do
is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf').
with_owner('0').
with_group('0').
with_mode('0644').
that_notifies('Class[Rabbitmq::Service]').
with_content("rabbitmq soft nofile #{value}\nrabbitmq hard nofile #{value}\n")
end
else
it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') }
end
if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) }
else
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
end
if facts[:systemd]
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_limits('LimitNOFILE' => value).
with_restart_service(false)
end
else
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
end
end
end
[-42, '-42', 'foo'].each do |value|
context "with file_limit => '#{value}'" do
let(:params) { { file_limit: value } }
it 'does not compile' do
expect { catalogue }.to raise_error(Puppet::PreformattedError, %r{Error while evaluating a Resource Statement})
end
end
end
context 'on systems with systemd', if: facts[:systemd] do
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_restart_service(false)
end
end
context 'on systems without systemd', unless: facts[:systemd] do
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
end
context 'with admin_enable set to true' do
let(:params) { { admin_enable: true, management_ip_address: '1.1.1.1' } }
context 'with service_manage set to true' do
let(:params) { { admin_enable: true, management_ip_address: '1.1.1.1', service_manage: true } }
context 'with rabbitmqadmin_package set to blub' do
let(:params) { { rabbitmqadmin_package: 'blub' } }
it 'installs a package called blub' do
is_expected.to contain_package('rabbitmqadmin').with_name('blub')
end
end
if facts[:os]['family'] == 'Archlinux'
it 'installs a package called rabbitmqadmin' do
is_expected.to contain_package('rabbitmqadmin').with_name('rabbitmqadmin')
end
else
it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
notify: 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
end
end
if %w[RedHat Debian SUSE].include?(facts[:os]['family'])
it { is_expected.to contain_package('python') }
end
if %w[FreeBSD OpenBSD].include?(facts[:os]['family'])
it { is_expected.to contain_package('python2') }
end
end
context 'with manage_python false' do
let(:params) { { manage_python: false } }
it do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.not_to contain_package('python')
is_expected.not_to contain_package('python2')
end
end
context 'with $management_ip_address undef and service_manage set to true', unless: facts[:osfamily] == 'Archlinux' do
let(:params) { { admin_enable: true, management_ip_address: :undef } }
it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
notify: 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://127.0.0.1:15672/cli/rabbitmqadmin')
end
end
context 'with service_manage set to true, node_ip_address = undef, and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do
let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', node_ip_address: :undef } }
it 'we use the correct URL to rabbitmqadmin' do
is_expected.to contain_archive('rabbitmqadmin').with(
source: 'http://127.0.0.1:15672/cli/rabbitmqadmin',
username: 'foobar',
password: 'hunter2'
)
end
end
context 'with service_manage set to true and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do
let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', management_ip_address: '1.1.1.1' } }
it 'we use the correct URL to rabbitmqadmin' do
is_expected.to contain_archive('rabbitmqadmin').with(
source: 'http://1.1.1.1:15672/cli/rabbitmqadmin',
username: 'foobar',
password: 'hunter2'
)
end
end
context 'with service_manage set to true and archive_options set', unless: facts[:osfamily] == 'Archlinux' do
let(:params) do
{
admin_enable: true,
management_ip_address: '1.1.1.1',
archive_options: %w[fizz pop]
}
end
it 'we use the correct archive_options to rabbitmqadmin' do
is_expected.to contain_archive('rabbitmqadmin').with(
source: 'http://1.1.1.1:15672/cli/rabbitmqadmin',
download_options: %w[fizz pop]
)
end
end
context 'with service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do
# note that the 2.x management port is 55672 not 15672
let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '1.1.1.1' } }
it 'we use the correct URL to rabbitmqadmin' do
is_expected.to contain_archive('rabbitmqadmin').with(
source: 'http://1.1.1.1:55672/cli/rabbitmqadmin',
username: 'guest',
password: 'guest'
)
end
end
context 'with ipv6, service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do
# note that the 2.x management port is 55672 not 15672
let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '::1' } }
it 'we use the correct URL to rabbitmqadmin' do
is_expected.to contain_archive('rabbitmqadmin').with(
source: 'http://[::1]:55672/cli/rabbitmqadmin',
username: 'guest',
password: 'guest'
)
end
end
context 'with service_manage set to false' do
let(:params) { { admin_enable: true, service_manage: false } }
it 'does nothing' do
is_expected.not_to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_management')
end
end
end
describe 'manages configuration directory correctly' do
it {
is_expected.to contain_file('/etc/rabbitmq').with(
'ensure' => 'directory',
'mode' => '0755'
)
}
end
describe 'manages configuration file correctly' do
it {
is_expected.to contain_file('rabbitmq.config').with(
'owner' => '0',
'group' => 'rabbitmq',
'mode' => '0640'
)
}
end
describe 'does not contain pre-ranch settings with default config' do
it do
is_expected.to contain_file('rabbitmq.config'). \
without_content(%r{binary,}). \
without_content(%r{\{packet, raw\},}). \
without_content(%r{\{reuseaddr, true\},})
end
end
describe 'contains pre-ranch settings with config_ranch set to false' do
let(:params) { { config_ranch: false } }
it do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{binary,}). \
with_content(%r{\{packet, raw\},}). \
with_content(%r{\{reuseaddr, true\},})
end
end
context 'configures config_cluster' do
let(:params) do
{
config_cluster: true,
cluster_nodes: ['hare-1', 'hare-2'],
cluster_node_type: 'ram',
wipe_db_on_cookie_change: false
}
end
describe 'with erlang_cookie set' do
let(:params) do
{
config_cluster: true,
cluster_nodes: ['hare-1', 'hare-2'],
cluster_node_type: 'ram',
erlang_cookie: 'TESTCOOKIE',
wipe_db_on_cookie_change: true
}
end
it 'contains the rabbitmq_erlang_cookie' do
is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
end
end
describe 'with erlang_cookie set but without config_cluster' do
let(:params) do
{
config_cluster: false,
erlang_cookie: 'TESTCOOKIE'
}
end
it 'contains the rabbitmq_erlang_cookie' do
is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
end
end
describe 'without erlang_cookie and without config_cluster' do
let(:params) do
{
config_cluster: false
}
end
it 'contains the rabbitmq_erlang_cookie' do
is_expected.not_to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
end
end
describe 'and sets appropriate configuration' do
let(:params) do
{
config_cluster: true,
cluster_nodes: ['hare-1', 'hare-2'],
cluster_node_type: 'ram',
erlang_cookie: 'ORIGINAL',
wipe_db_on_cookie_change: true
}
end
it 'for cluster_nodes' do
is_expected.to contain_file('rabbitmq.config').with('content' => %r{cluster_nodes.*\['rabbit@hare-1', 'rabbit@hare-2'\], ram})
end
end
end
describe 'rabbitmq-env configuration' do
context 'with default params' do
it 'sets environment variables' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{ERL_INETRC=/etc/rabbitmq/inetrc})
end
end
context 'with environment_variables set' do
let(:params) do
{ 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'
} }
end
it 'sets environment variables' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{NODE_IP_ADDRESS=1.1.1.1}). \
with_content(%r{NODE_PORT=5656}). \
with_content(%r{NODENAME=HOSTNAME}). \
with_content(%r{SERVICENAME=RabbitMQ}). \
with_content(%r{CONSOLE_LOG=RabbitMQ.debug}). \
with_content(%r{CTL_ERL_ARGS=verbose}). \
with_content(%r{SERVER_ERL_ARGS=v}). \
with_content(%r{SERVER_START_ARGS=debug})
end
end
end
context 'delete_guest_user' do
describe 'should do nothing by default' do
it { is_expected.not_to 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
is_expected.to 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 'sets NODE_IP_ADDRESS to specified value' do
is_expected.to contain_file('rabbitmq-env.config').
with_content(%r{NODE_IP_ADDRESS=172\.0\.0\.1})
end
end
describe 'stomp by default' do
it 'does not specify stomp parameters in rabbitmq.config' do
is_expected.to contain_file('rabbitmq.config').without('content' => %r{stomp})
end
end
describe 'stomp when set' do
let(:params) { { config_stomp: true, stomp_port: 5679 } }
it 'specifies stomp port in rabbitmq.config' do
is_expected.to contain_file('rabbitmq.config').with('content' => %r{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 'does not configure ssl_listeners in rabbitmq.config' do
is_expected.to contain_file('rabbitmq.config').without('content' => %r{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 'specifies stomp port and ssl stomp port in rabbitmq.config' do
is_expected.to contain_file('rabbitmq.config').with('content' => %r{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_other_bind: 'as_user',
ldap_use_ssl: false,
ldap_port: 389,
ldap_log: true,
ldap_config_variables: { 'foo' => 'bar' } }
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
it 'contains ldap parameters' do
verify_contents(catalogue, 'rabbitmq.config',
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
' {servers, ["ldap.example.com"]},',
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
' {port, 389},', ' {foo, bar},', ' {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_other_bind: 'as_user',
ldap_use_ssl: false,
ldap_port: 389,
ldap_log: true,
ldap_config_variables: { 'foo' => 'bar' } }
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
it 'contains ldap parameters' do
verify_contents(catalogue, 'rabbitmq.config',
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
' {servers, ["ldap.example.com"]},',
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
' {port, 389},', ' {foo, bar},', ' {log, true}'])
end
end
describe 'configuring ldap authentication' do
let :params do
{ config_stomp: false,
ldap_auth: true,
ldap_server: 'ldap.example.com',
ldap_other_bind: 'as_user',
ldap_use_ssl: false,
ldap_port: 389,
ldap_log: true,
ldap_config_variables: { 'foo' => 'bar' } }
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
it 'does not set user_dn_pattern when none is specified' do
verify_contents(catalogue, 'rabbitmq.config',
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
' {servers, ["ldap.example.com"]},',
' {use_ssl, false},',
' {port, 389},', ' {foo, bar},', ' {log, true}'])
content = catalogue.resource('file', 'rabbitmq.config').send(:parameters)[:content]
expect(content).not_to include 'user_dn_pattern'
end
end
describe 'configuring auth_backends' do
let :params do
{ auth_backends: ['{baz, foo}', 'bar'] }
end
it 'contains auth_backends' do
verify_contents(catalogue, 'rabbitmq.config',
[' {auth_backends, [{baz, foo}, bar]},'])
end
end
describe 'auth_backends overrides ldap_auth' do
let :params do
{ auth_backends: ['{baz, foo}', 'bar'],
ldap_auth: true }
end
it 'contains auth_backends' do
verify_contents(catalogue, 'rabbitmq.config',
[' {auth_backends, [{baz, foo}, bar]},'])
end
end
context 'use config file for plugins' do
describe 'config_plugins_file: true' do
let :params do
{ use_config_file_for_plugins: true }
end
it 'does not use rabbitmqplugin provider' do
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_management')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_stomp')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel')
end
it 'configures enabled_plugins' do
is_expected.to contain_file('enabled_plugins').with_content(%r{\[rabbitmq_management\]\.})
end
end
describe 'with all plugins enabled admin_enable: false, manamgent_enable: true' do
let :params do
{
use_config_file_for_plugins: true,
admin_enable: false,
management_enable: true,
stomp_ensure: true,
ldap_auth: true,
config_shovel: true
}
end
it 'does not use rabbitmqplugin provider' do
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_management')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_stomp')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap')
is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel')
end
it 'configures enabled_plugins' do
is_expected.to contain_file('enabled_plugins').with_content(%r{rabbitmq_management})
is_expected.to contain_file('enabled_plugins').with_content(%r{rabbitmq_stomp})
is_expected.to contain_file('enabled_plugins').with_content(%r{rabbitmq_auth_backend_ldap})
is_expected.to contain_file('enabled_plugins').with_content(%r{rabbitmq_shovel})
is_expected.to contain_file('enabled_plugins').with_content(%r{rabbitmq_shovel_management})
is_expected.to contain_file('enabled_plugins').with_content(%r{\[rabbitmq_management,rabbitmq_stomp,rabbitmq_auth_backend_ldap,rabbitmq_shovel,rabbitmq_shovel_management\]\.})
end
end
end
describe 'configure management plugin' do
let :params do
{
admin_enable: true,
management_enable: false
}
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_management') }
it 'sets rabbitmq_managment opts to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 15672\}})
end
describe 'with admin_enable false' do
let :params do
{
admin_enable: false,
management_enable: false
}
end
it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_management') }
end
describe 'with admin_enable false and management_enable true' do
let :params do
{
admin_enable: false,
management_enable: true
}
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_management') }
it 'sets rabbitmq_managment opts to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 15672\}})
end
end
end
describe 'configuring shovel plugin' do
let :params do
{
config_shovel: true
}
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel') }
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
describe 'with admin_enable false' do
let :params do
{
config_shovel: true,
admin_enable: false
}
end
it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
end
describe 'with static shovels' do
let :params do
{
config_shovel: true,
config_shovel_statics: {
'shovel_first' => '{sources,[{broker,"amqp://"}]},
{destinations,[{broker,"amqp://site1.example.com"}]},
{queue,<<"source_one">>}',
'shovel_second' => '{sources,[{broker,"amqp://"}]},
{destinations,[{broker,"amqp://site2.example.com"}]},
{queue,<<"source_two">>}'
}
}
end
it 'generates correct configuration' do
verify_contents(catalogue, 'rabbitmq.config', [
' {rabbitmq_shovel,',
' [{shovels,[',
' {shovel_first,[{sources,[{broker,"amqp://"}]},',
' {destinations,[{broker,"amqp://site1.example.com"}]},',
' {queue,<<"source_one">>}]},',
' {shovel_second,[{sources,[{broker,"amqp://"}]},',
' {destinations,[{broker,"amqp://site2.example.com"}]},',
' {queue,<<"source_two">>}]}',
' ]}]}'
])
end
end
end
describe 'configuring shovel plugin' do
let :params do
{
config_shovel: true
}
end
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel') }
it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
describe 'with admin_enable false' do
let :params do
{
config_shovel: true,
admin_enable: false
}
end
it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
end
describe 'with static shovels' do
let :params do
{
config_shovel: true,
config_shovel_statics: {
'shovel_first' => '{sources,[{broker,"amqp://"}]},
{destinations,[{broker,"amqp://site1.example.com"}]},
{queue,<<"source_one">>}',
'shovel_second' => '{sources,[{broker,"amqp://"}]},
{destinations,[{broker,"amqp://site2.example.com"}]},
{queue,<<"source_two">>}'
}
}
end
it 'generates correct configuration' do
verify_contents(catalogue, 'rabbitmq.config', [
' {rabbitmq_shovel,',
' [{shovels,[',
' {shovel_first,[{sources,[{broker,"amqp://"}]},',
' {destinations,[{broker,"amqp://site1.example.com"}]},',
' {queue,<<"source_one">>}]},',
' {shovel_second,[{sources,[{broker,"amqp://"}]},',
' {destinations,[{broker,"amqp://site2.example.com"}]},',
' {queue,<<"source_two">>}]}',
' ]}]}'
])
end
end
end
describe 'default_user and default_pass set' do
let(:params) { { default_user: 'foo', default_pass: 'bar' } }
it 'sets default_user and default_pass to specified values' do
is_expected.to contain_file('rabbitmq.config').with('content' => %r{default_user, <<"foo">>.*default_pass, <<"bar">>}m)
end
end
describe 'interfaces option with no ssl' do
let(:params) do
{ interface: '0.0.0.0' }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\{"0.0.0.0", 5672\}\]})
end
end
describe 'ssl options and mangament_ssl false' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_secure_renegotiate: true,
ssl_reuse_sessions: true,
ssl_honor_cipher_order: true,
ssl_dhfile: :undef,
management_ssl: false,
management_port: 13_142 }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_listeners, \[3141\]}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_options, \[}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{cacertfile,"/path/to/cacert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{certfile,"/path/to/cert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{keyfile,"/path/to/key"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{secure_renegotiate,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{reuse_sessions,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{honor_cipher_order,true}
)
is_expected.to contain_file('rabbitmq.config').without_content(
%r{dhfile,}
)
end
it 'sets non ssl port for management port' do
is_expected.to contain_file('rabbitmq.config').with_content(
%r{port, 13142}
)
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{port\s=\s13142}
)
end
end
describe 'ssl options and mangament_ssl true' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_secure_renegotiate: true,
ssl_reuse_sessions: true,
ssl_honor_cipher_order: true,
ssl_dhfile: :undef,
management_ssl: true,
ssl_management_port: 13_141 }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_listeners, \[3141\]}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_opts, }
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_options, \[}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{cacertfile,"/path/to/cacert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{certfile,"/path/to/cert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{keyfile,"/path/to/key"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{secure_renegotiate,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{reuse_sessions,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{honor_cipher_order,true}
)
is_expected.to contain_file('rabbitmq.config').without_content(
%r{dhfile,}
)
end
it 'sets ssl managment port to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(
%r{port, 13141}
)
end
it 'sets ssl options in the rabbitmqadmin.conf' do
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{ssl_ca_cert_file\s=\s/path/to/cacert}
)
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{ssl_cert_file\s=\s/path/to/cert}
)
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{ssl_key_file\s=\s/path/to/key}
)
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{hostname\s=\s}
)
is_expected.to contain_file('rabbitmqadmin.conf').with_content(
%r{port\s=\s13141}
)
end
end
describe 'ssl options' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_secure_renegotiate: true,
ssl_reuse_sessions: true,
ssl_honor_cipher_order: true,
ssl_dhfile: :undef }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_listeners, \[3141\]}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{ssl_options, \[}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{cacertfile,"/path/to/cacert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{certfile,"/path/to/cert"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{keyfile,"/path/to/key"}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{secure_renegotiate,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{reuse_sessions,true}
)
is_expected.to contain_file('rabbitmq.config').with_content(
%r{honor_cipher_order,true}
)
is_expected.to contain_file('rabbitmq.config').without_content(
%r{dhfile,}
)
end
end
describe 'ssl options with ssl_interfaces' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_interface: '0.0.0.0',
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key' }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
end
end
describe 'ssl options with ssl_only' do
let(:params) do
{ ssl: true,
ssl_only: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key' }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[3141\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_options, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
end
it 'does not set TCP listener environment defaults' do
is_expected.to contain_file('rabbitmq-env.config'). \
without_content(%r{NODE_PORT=}). \
without_content(%r{NODE_IP_ADDRESS=})
end
end
describe 'ssl options with ssl_only and ssl_interfaces' do
let(:params) do
{ ssl: true,
ssl_only: true,
ssl_port: 3141,
ssl_interface: '0.0.0.0',
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key' }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
end
end
describe 'ssl options with specific ssl versions' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_versions: ['tlsv1.2', 'tlsv1.1'] }
end
it 'sets ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[3141\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_options, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile,"/path/to/cacert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl, \[\{versions, \['tlsv1.1', 'tlsv1.2'\]\}\]})
is_expected.to contain_file('rabbitmq.config').with_content(%r{versions, \['tlsv1.1', 'tlsv1.2'\]})
end
end
describe 'ssl options with ssl_versions and not ssl' do
let(:params) do
{ ssl: false,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_versions: ['tlsv1.2', 'tlsv1.1'] }
end
it 'fails' do
expect { catalogue }.to raise_error(Puppet::Error, %r{\$ssl_versions requires that \$ssl => true})
end
end
describe 'ssl options with ssl ciphers' do
let(:params) do
{ ssl: true,
ssl_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_ciphers: ['ecdhe_rsa,aes_256_cbc,sha', 'dhe_rsa,aes_256_cbc,sha'] }
end
it 'sets ssl ciphers to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{ciphers,\[[[:space:]]+{dhe_rsa,aes_256_cbc,sha},[[:space:]]+{ecdhe_rsa,aes_256_cbc,sha}[[:space:]]+\]})
end
end
describe 'ssl admin options with specific ssl versions' do
let(:params) do
{ ssl: true,
ssl_management_port: 5926,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_versions: ['tlsv1.2', 'tlsv1.1'],
admin_enable: true }
end
it 'sets admin ssl opts to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 5926\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl, true\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile, "/path/to/cacert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{,\{versions, \['tlsv1.1', 'tlsv1.2'\]\}})
end
end
describe 'ssl with ssl_dhfile' do
let(:params) do
{ ssl: true,
ssl_interface: '0.0.0.0',
ssl_dhfile: '/etc/pki/tls/dh-params.pem' }
end
it { is_expected.to contain_file('rabbitmq.config').with_content(%r{dhfile, "/etc/pki/tls/dh-params\.pem}) }
end
describe 'ssl with ssl_dhfile unset' do
let(:params) do
{ ssl: true,
ssl_interface: '0.0.0.0',
ssl_dhfile: :undef }
end
it { is_expected.to contain_file('rabbitmq.config').without_content(%r{dhfile,}) }
end
describe 'ssl with ssl_secure_renegotiate false' do
let(:params) do
{ ssl: true,
ssl_interface: '0.0.0.0',
ssl_secure_renegotiate: false }
end
it { is_expected.to contain_file('rabbitmq.config').with_content(%r{secure_renegotiate,false}) }
end
describe 'ssl with ssl_reuse_sessions false' do
let(:params) do
{ ssl: true,
ssl_interface: '0.0.0.0',
ssl_reuse_sessions: false }
end
it { is_expected.to contain_file('rabbitmq.config').with_content(%r{reuse_sessions,false}) }
end
describe 'ssl with ssl_honor_cipher_order false' do
let(:params) do
{ ssl: true,
ssl_interface: '0.0.0.0',
ssl_honor_cipher_order: false }
end
it { is_expected.to contain_file('rabbitmq.config').with_content(%r{honor_cipher_order,false}) }
end
describe 'ssl admin options' do
let(:params) do
{ ssl: true,
ssl_management_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
ssl_management_verify: 'verify_peer',
ssl_management_fail_if_no_peer_cert: true,
admin_enable: true }
end
it 'sets rabbitmq_management ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl, true\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{verify,verify_peer\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{fail_if_no_peer_cert,true\}})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile, "/path/to/cacert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}})
end
end
describe 'admin without ssl' do
let(:params) do
{ ssl: false,
management_port: 3141,
admin_enable: true }
end
it 'sets rabbitmq_management options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 3141\}})
end
end
describe 'ssl admin options' do
let(:params) do
{ ssl: true,
ssl_management_port: 3141,
ssl_cacert: '/path/to/cacert',
ssl_cert: '/path/to/cert',
ssl_key: '/path/to/key',
admin_enable: true }
end
it 'sets rabbitmq_management ssl options to specified values' do
is_expected.to contain_file('rabbitmq.config').with_content(%r{rabbitmq_management, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{listener, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{port, 3141\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl, true\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{ssl_opts, \[})
is_expected.to contain_file('rabbitmq.config').with_content(%r{cacertfile, "/path/to/cacert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{certfile, "/path/to/cert"\},})
is_expected.to contain_file('rabbitmq.config').with_content(%r{keyfile, "/path/to/key"\}})
end
end
describe 'admin without ssl' do
let(:params) do
{ ssl: false,
management_port: 3141,
admin_enable: true }
end
it 'sets rabbitmq_management options to specified values' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{rabbitmq_management, \[}). \
with_content(%r{\{listener, \[}). \
with_content(%r{\{port, 3141\}})
end
end
describe 'ipv6 enabled' do
let(:params) { { ipv6: true } }
it 'enables resolver inet6 in inetrc' do
is_expected.to contain_file('rabbitmq-inetrc').with_content(%r{{inet6, true}.})
end
context 'without other erl args' do
it 'enables inet6 distribution' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS="-proto_dist inet6_tcp"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS="-proto_dist inet6_tcp"$})
end
end
context 'with other quoted erl args' do
let(:params) do
{ ipv6: true,
environment_variables: { 'RABBITMQ_SERVER_ERL_ARGS' => '"some quoted args"',
'RABBITMQ_CTL_ERL_ARGS' => '"other quoted args"' } }
end
it 'enables inet6 distribution and quote properly' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS="some quoted args -proto_dist inet6_tcp"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS="other quoted args -proto_dist inet6_tcp"$})
end
end
context 'with other unquoted erl args' do
let(:params) do
{ ipv6: true,
environment_variables: { 'RABBITMQ_SERVER_ERL_ARGS' => 'foo',
'RABBITMQ_CTL_ERL_ARGS' => 'bar' } }
end
it 'enables inet6 distribution and quote properly' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS="foo -proto_dist inet6_tcp"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS="bar -proto_dist inet6_tcp"$})
end
end
context 'with SSL and without other erl args' do
let(:params) do
{ ipv6: true,
ssl_erl_dist: true }
end
it 'enables inet6 distribution' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS=" -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS=" -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$})
end
end
context 'with SSL and other quoted erl args' do
let(:params) do
{ ipv6: true,
ssl_erl_dist: true,
environment_variables: { 'RABBITMQ_SERVER_ERL_ARGS' => '"some quoted args"',
'RABBITMQ_CTL_ERL_ARGS' => '"other quoted args"' } }
end
it 'enables inet6 distribution and quote properly' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS="some quoted args -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS="other quoted args -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$})
end
end
context 'with SSL and with other unquoted erl args' do
let(:params) do
{ ipv6: true,
ssl_erl_dist: true,
environment_variables: { 'RABBITMQ_SERVER_ERL_ARGS' => 'foo',
'RABBITMQ_CTL_ERL_ARGS' => 'bar' } }
end
it 'enables inet6 distribution and quote properly' do
is_expected.to contain_file('rabbitmq-env.config'). \
with_content(%r{^RABBITMQ_SERVER_ERL_ARGS="foo -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$}). \
with_content(%r{^RABBITMQ_CTL_ERL_ARGS="bar -pa /usr/lib64/erlang/lib/ssl-7.3.3.1/ebin -proto_dist inet6_tls"$})
end
end
end
describe 'config_variables options' do
let(:params) do
{ config_variables: {
'hipe_compile' => true,
'vm_memory_high_watermark' => 0.4,
'frame_max' => 131_072,
'collect_statistics' => 'none',
'auth_mechanisms' => "['PLAIN', 'AMQPLAIN']"
} }
end
it 'sets environment variables' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{hipe_compile, true\}}). \
with_content(%r{\{vm_memory_high_watermark, 0.4\}}). \
with_content(%r{\{frame_max, 131072\}}). \
with_content(%r{\{collect_statistics, none\}}). \
with_content(%r{\{auth_mechanisms, \['PLAIN', 'AMQPLAIN'\]\}})
end
end
describe 'config_kernel_variables options' do
let(:params) do
{ config_kernel_variables: {
'inet_dist_listen_min' => 9100,
'inet_dist_listen_max' => 9105
} }
end
it 'sets config variables' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{inet_dist_listen_min, 9100\}}). \
with_content(%r{\{inet_dist_listen_max, 9105\}})
end
end
describe 'config_management_variables' do
let(:params) do
{ config_management_variables: {
'rates_mode' => 'none'
} }
end
it 'sets config variables' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{rates_mode, none\}})
end
end
describe 'tcp_keepalive enabled' do
let(:params) { { tcp_keepalive: true } }
it 'sets tcp_listen_options keepalive true' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{keepalive, true\}})
end
end
describe 'tcp_keepalive disabled (default)' do
it 'does not set tcp_listen_options' do
is_expected.to contain_file('rabbitmq.config'). \
without_content(%r{\{keepalive, true\}})
end
end
describe 'tcp_backlog with default value' do
it 'sets tcp_listen_options backlog to 128' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{backlog, 128\}})
end
end
describe 'tcp_backlog with non-default value' do
let(:params) do
{ tcp_backlog: 256 }
end
it 'sets tcp_listen_options backlog to 256' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{backlog, 256\}})
end
end
describe 'tcp_sndbuf with default value' do
it 'does not set tcp_listen_options sndbuf' do
is_expected.to contain_file('rabbitmq.config'). \
without_content(%r{sndbuf})
end
end
describe 'tcp_sndbuf with non-default value' do
let(:params) do
{ tcp_sndbuf: 128 }
end
it 'sets tcp_listen_options sndbuf to 128' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{sndbuf, 128\}})
end
end
describe 'tcp_recbuf with default value' do
it 'does not set tcp_listen_options recbuf' do
is_expected.to contain_file('rabbitmq.config'). \
without_content(%r{recbuf})
end
end
describe 'tcp_recbuf with non-default value' do
let(:params) do
{ tcp_recbuf: 128 }
end
it 'sets tcp_listen_options recbuf to 128' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{recbuf, 128\}})
end
end
describe 'rabbitmq-heartbeat options' do
let(:params) { { heartbeat: 60 } }
it 'sets heartbeat paramter in config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{heartbeat, 60\}})
end
end
context 'delete_guest_user' do
describe 'should do nothing by default' do
it { is_expected.not_to 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
is_expected.to contain_rabbitmq_user('guest').with(
'ensure' => 'absent',
'provider' => 'rabbitmqctl'
)
end
end
end
describe 'rabbitmq-loopback_users by default' do
it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[<<"guest">>\]\}})
end
end
describe 'rabbitmq-loopback_users allow connections via loopback interfaces' do
let(:params) { { loopback_users: [] } }
it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[\]\}})
end
end
describe 'rabbitmq-loopback_users allow connections via loopback interfaces to a group of users' do
let(:params) { { loopback_users: %w[user1 user2] } }
it 'sets the loopback_users parameter in the config file' do
is_expected.to contain_file('rabbitmq.config'). \
with_content(%r{\{loopback_users, \[<<\"user1\">>, <<\"user2\">>\]\}})
end
end
##
## rabbitmq::service
##
describe 'service with default params' do
it {
is_expected.to contain_service('rabbitmq-server').with(
'ensure' => 'running',
'enable' => 'true',
'hasstatus' => 'true',
'hasrestart' => 'true',
'name' => name
)
}
end
context 'on systems with systemd', if: facts[:systemd] do
it do
is_expected.to contain_service('rabbitmq-server').
that_requires('Class[systemd::systemctl::daemon_reload]')
end
end
describe 'service with ensure stopped' do
let :params do
{ service_ensure: 'stopped' }
end
it {
is_expected.to contain_service('rabbitmq-server').with(
'ensure' => 'stopped',
'enable' => false
)
}
end
describe 'service with service_manage equal to false' do
let :params do
{ service_manage: false }
end
it { is_expected.not_to contain_service('rabbitmq-server') }
end
end
end
end

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 18, 4:36 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3326452

Event Timeline