diff --git a/.msync.yml b/.msync.yml index 8864fc0..4c7999c 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.12.0' +modulesync_config_version: '3.0.0' diff --git a/.rubocop.yml b/.rubocop.yml index c2ebc88..316e4ec 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,546 +1,549 @@ require: rubocop-rspec AllCops: # Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5 TargetRubyVersion: 1.9 Include: - ./**/*.rb Exclude: - files/**/* - vendor/**/* - .vendor/**/* - pkg/**/* - spec/fixtures/**/* - Gemfile - Rakefile - Guardfile - Vagrantfile Lint/ConditionPosition: Enabled: True Lint/ElseLayout: Enabled: True Lint/UnreachableCode: Enabled: True Lint/UselessComparison: Enabled: True Lint/EnsureReturn: Enabled: True Lint/HandleExceptions: Enabled: True Lint/LiteralInCondition: Enabled: True Lint/ShadowingOuterLocalVariable: Enabled: True Lint/LiteralInInterpolation: Enabled: True Style/HashSyntax: Enabled: True Style/RedundantReturn: Enabled: True Layout/EndOfLine: Enabled: False Lint/AmbiguousOperator: Enabled: True Lint/AssignmentInCondition: Enabled: True Layout/SpaceBeforeComment: Enabled: True Style/AndOr: Enabled: True Style/RedundantSelf: Enabled: True Metrics/BlockLength: Enabled: False # Method length is not necessarily an indicator of code quality Metrics/MethodLength: Enabled: False # Module length is not necessarily an indicator of code quality Metrics/ModuleLength: Enabled: False Style/WhileUntilModifier: Enabled: True Lint/AmbiguousRegexpLiteral: Enabled: True Security/Eval: Enabled: True Lint/BlockAlignment: Enabled: True Lint/DefEndAlignment: Enabled: True Lint/EndAlignment: Enabled: True Lint/DeprecatedClassMethods: Enabled: True Lint/Loop: Enabled: True Lint/ParenthesesAsGroupedExpression: Enabled: True Lint/RescueException: Enabled: True Lint/StringConversionInInterpolation: Enabled: True Lint/UnusedBlockArgument: Enabled: True Lint/UnusedMethodArgument: Enabled: True Lint/UselessAccessModifier: Enabled: True Lint/UselessAssignment: Enabled: True Lint/Void: Enabled: True Layout/AccessModifierIndentation: Enabled: True Style/AccessorMethodName: Enabled: True Style/Alias: Enabled: True Layout/AlignArray: Enabled: True Layout/AlignHash: Enabled: True Layout/AlignParameters: Enabled: True Metrics/BlockNesting: Enabled: True Style/AsciiComments: Enabled: True Style/Attr: Enabled: True Style/BracesAroundHashParameters: Enabled: True Style/CaseEquality: Enabled: True Layout/CaseIndentation: Enabled: True Style/CharacterLiteral: Enabled: True Style/ClassAndModuleCamelCase: Enabled: True Style/ClassAndModuleChildren: Enabled: False Style/ClassCheck: Enabled: True # Class length is not necessarily an indicator of code quality Metrics/ClassLength: Enabled: False Style/ClassMethods: Enabled: True Style/ClassVars: Enabled: True Style/WhenThen: Enabled: True Style/WordArray: Enabled: True Style/UnneededPercentQ: Enabled: True Layout/Tab: Enabled: True Layout/SpaceBeforeSemicolon: Enabled: True Layout/TrailingBlankLines: Enabled: True Layout/SpaceInsideBlockBraces: Enabled: True Layout/SpaceInsideBrackets: Enabled: True Layout/SpaceInsideHashLiteralBraces: Enabled: True Layout/SpaceInsideParens: Enabled: True Layout/LeadingCommentSpace: Enabled: True Layout/SpaceBeforeFirstArg: Enabled: True Layout/SpaceAfterColon: Enabled: True Layout/SpaceAfterComma: Enabled: True Layout/SpaceAfterMethodName: Enabled: True Layout/SpaceAfterNot: Enabled: True Layout/SpaceAfterSemicolon: Enabled: True Layout/SpaceAroundEqualsInParameterDefault: Enabled: True Layout/SpaceAroundOperators: Enabled: True Layout/SpaceBeforeBlockBraces: Enabled: True Layout/SpaceBeforeComma: Enabled: True Style/CollectionMethods: Enabled: True Layout/CommentIndentation: Enabled: True Style/ColonMethodCall: Enabled: True Style/CommentAnnotation: Enabled: True # 'Complexity' is very relative Metrics/CyclomaticComplexity: Enabled: False Style/ConstantName: Enabled: True Style/Documentation: Enabled: False Style/DefWithParentheses: Enabled: True Style/PreferredHashMethods: Enabled: True Layout/DotPosition: EnforcedStyle: trailing Style/DoubleNegation: Enabled: True Style/EachWithObject: Enabled: True Layout/EmptyLineBetweenDefs: Enabled: True Layout/IndentArray: Enabled: True Layout/IndentHash: Enabled: True Layout/IndentationConsistency: Enabled: True Layout/IndentationWidth: Enabled: True Layout/EmptyLines: Enabled: True Layout/EmptyLinesAroundAccessModifier: Enabled: True Style/EmptyLiteral: Enabled: True # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: Enabled: False Style/MethodCallWithoutArgsParentheses: Enabled: True Style/MethodDefParentheses: Enabled: True Style/LineEndConcatenation: Enabled: True Layout/TrailingWhitespace: Enabled: True Style/StringLiterals: Enabled: True Style/TrailingCommaInArguments: Enabled: True Style/TrailingCommaInLiteral: Enabled: True Style/GlobalVars: Enabled: True Style/GuardClause: Enabled: True Style/IfUnlessModifier: Enabled: True Style/MultilineIfThen: Enabled: True Style/NegatedIf: Enabled: True Style/NegatedWhile: Enabled: True Style/Next: Enabled: True Style/SingleLineBlockParams: Enabled: True Style/SingleLineMethods: Enabled: True Style/SpecialGlobalVars: Enabled: True Style/TrivialAccessors: Enabled: True Style/UnlessElse: Enabled: True Style/VariableInterpolation: Enabled: True Style/VariableName: Enabled: True Style/WhileUntilDo: Enabled: True Style/EvenOdd: Enabled: True Style/FileName: Enabled: True Style/For: Enabled: True Style/Lambda: Enabled: True Style/MethodName: Enabled: True Style/MultilineTernaryOperator: Enabled: True Style/NestedTernaryOperator: Enabled: True Style/NilComparison: Enabled: True Style/FormatString: Enabled: True Style/MultilineBlockChain: Enabled: True Style/Semicolon: Enabled: True Style/SignalException: Enabled: True Style/NonNilCheck: Enabled: True Style/Not: Enabled: True Style/NumericLiterals: Enabled: True Style/OneLineConditional: Enabled: True Style/OpMethod: Enabled: True Style/ParenthesesAroundCondition: Enabled: True Style/PercentLiteralDelimiters: Enabled: True Style/PerlBackrefs: Enabled: True Style/PredicateName: Enabled: True Style/RedundantException: Enabled: True Style/SelfAssignment: Enabled: True Style/Proc: Enabled: True Style/RaiseArgs: Enabled: True Style/RedundantBegin: Enabled: True Style/RescueModifier: Enabled: True # based on https://github.com/voxpupuli/modulesync_config/issues/168 Style/RegexpLiteral: EnforcedStyle: percent_r Enabled: True Lint/UnderscorePrefixedVariableName: Enabled: True Metrics/ParameterLists: Enabled: False Lint/RequireParentheses: Enabled: True Style/ModuleFunction: Enabled: True Lint/Debugger: Enabled: True Style/IfWithSemicolon: Enabled: True Style/Encoding: Enabled: True Style/BlockDelimiters: Enabled: True Layout/MultilineBlockLayout: Enabled: True # 'Complexity' is very relative Metrics/AbcSize: Enabled: False # 'Complexity' is very relative Metrics/PerceivedComplexity: Enabled: False Lint/UselessAssignment: Enabled: True Layout/ClosingParenthesisIndentation: Enabled: True # RSpec RSpec/BeforeAfterAll: Exclude: - spec/acceptance/**/* # We don't use rspec in this way RSpec/DescribeClass: Enabled: False # Example length is not necessarily an indicator of code quality RSpec/ExampleLength: Enabled: False RSpec/NamedSubject: Enabled: False # disabled for now since they cause a lot of issues # these issues aren't easy to fix RSpec/RepeatedDescription: Enabled: False RSpec/NestedGroups: Enabled: False +RSpec/MultipleExpectations: + Enabled: false + # this is broken on ruby1.9 Layout/IndentHeredoc: Enabled: False # disable Yaml safe_load. This is needed to support ruby2.0.0 development envs Security/YAMLLoad: Enabled: false # This affects hiera interpolation, as well as some configs that we push. Style/FormatStringToken: Enabled: false # This is useful, but sometimes a little too picky about where unit tests files # are located. RSpec/FilePath: Enabled: false diff --git a/Gemfile b/Gemfile index 87db4f9..8592cd6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,48 +1,48 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :test do - gem 'voxpupuli-test', '>= 1.4.0', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false + gem 'voxpupuli-test', '~> 2.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false end group :development do gem 'travis', :require => false gem 'travis-lint', :require => false gem 'guard-rake', :require => false gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do gem 'voxpupuli-acceptance', :require => false end group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false gem 'puppet-strings', '>= 2.2', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else gem 'facter', :require => false, :groups => [:test] end ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 6.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/examples/erlang_deps.pp b/examples/erlang_deps.pp index 20cd6b5..16e566a 100644 --- a/examples/erlang_deps.pp +++ b/examples/erlang_deps.pp @@ -1,5 +1,5 @@ # install first the garethr-erlang module. See README.md include erlang -class { 'erlang': epel_enable => true} +class { 'erlang': epel_enable => true } Class['erlang'] -> Class['rabbitmq'] diff --git a/examples/plugin.pp b/examples/plugin.pp index 01b8fbd..878fb94 100644 --- a/examples/plugin.pp +++ b/examples/plugin.pp @@ -1,11 +1,11 @@ -$rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ] +$rabbitmq_plugins = ['amqp_client', 'rabbitmq_stomp'] class { 'rabbitmq': config_stomp => true, } rabbitmq_plugin { $rabbitmq_plugins: ensure => present, require => Class['rabbitmq'], provider => 'rabbitmqplugins', } diff --git a/examples/site.pp b/examples/site.pp index a3b19d4..0bb1907 100644 --- a/examples/site.pp +++ b/examples/site.pp @@ -1,16 +1,14 @@ node default { - - $rabbitmq_plugins = [ 'amqp_client', 'rabbitmq_stomp' ] + $rabbitmq_plugins = ['amqp_client', 'rabbitmq_stomp'] class { 'rabbitmq': config => '[ {rabbit_stomp, [{tcp_listeners, [1234]} ]} ].', } # Required for MCollective rabbitmq_plugin { $rabbitmq_plugins: ensure => present, require => Class['rabbitmq'], provider => 'rabbitmqplugins', } } - diff --git a/manifests/config.pp b/manifests/config.pp index 65f0319..5373109 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,254 +1,253 @@ # Sets all the configuration values for RabbitMQ and creates the directories for # config and ssl. # # @api private class rabbitmq::config { - $admin_enable = $rabbitmq::admin_enable $management_enable = $rabbitmq::management_enable $use_config_file_for_plugins = $rabbitmq::use_config_file_for_plugins $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_ranch = $rabbitmq::config_ranch $config_stomp = $rabbitmq::config_stomp $stomp_ensure = $rabbitmq::stomp_ensure $config_shovel = $rabbitmq::config_shovel $config_shovel_statics = $rabbitmq::config_shovel_statics $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 $interface = $rabbitmq::interface $management_port = $rabbitmq::management_port $management_ssl = $rabbitmq::management_ssl $management_hostname = $rabbitmq::management_hostname $node_ip_address = $rabbitmq::node_ip_address $rabbitmq_user = $rabbitmq::rabbitmq_user $rabbitmq_group = $rabbitmq::rabbitmq_group $rabbitmq_home = $rabbitmq::rabbitmq_home $port = $rabbitmq::port $tcp_keepalive = $rabbitmq::tcp_keepalive $tcp_backlog = $rabbitmq::tcp_backlog $tcp_sndbuf = $rabbitmq::tcp_sndbuf $tcp_recbuf = $rabbitmq::tcp_recbuf $heartbeat = $rabbitmq::heartbeat $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_depth = $rabbitmq::ssl_depth $ssl_cert_password = $rabbitmq::ssl_cert_password $ssl_port = $rabbitmq::ssl_port $ssl_interface = $rabbitmq::ssl_interface $ssl_management_port = $rabbitmq::ssl_management_port $ssl_management_cacert = $rabbitmq::ssl_management_cacert $ssl_management_cert = $rabbitmq::ssl_management_cert $ssl_management_key = $rabbitmq::ssl_management_key $ssl_management_verify = $rabbitmq::ssl_management_verify $ssl_management_fail_if_no_peer_cert = $rabbitmq::ssl_management_fail_if_no_peer_cert $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 $ssl_secure_renegotiate = $rabbitmq::ssl_secure_renegotiate $ssl_reuse_sessions = $rabbitmq::ssl_reuse_sessions $ssl_honor_cipher_order = $rabbitmq::ssl_honor_cipher_order $ssl_dhfile = $rabbitmq::ssl_dhfile $ssl_versions = $rabbitmq::ssl_versions $ssl_ciphers = $rabbitmq::ssl_ciphers $stomp_port = $rabbitmq::stomp_port $stomp_ssl_only = $rabbitmq::stomp_ssl_only $ldap_auth = $rabbitmq::ldap_auth $ldap_server = $rabbitmq::ldap_server $ldap_user_dn_pattern = $rabbitmq::ldap_user_dn_pattern $ldap_other_bind = $rabbitmq::ldap_other_bind $ldap_use_ssl = $rabbitmq::ldap_use_ssl $ldap_port = $rabbitmq::ldap_port $ldap_log = $rabbitmq::ldap_log $ldap_config_variables = $rabbitmq::ldap_config_variables $wipe_db_on_cookie_change = $rabbitmq::wipe_db_on_cookie_change $config_variables = $rabbitmq::config_variables $config_kernel_variables = $rabbitmq::config_kernel_variables $config_management_variables = $rabbitmq::config_management_variables $config_additional_variables = $rabbitmq::config_additional_variables $auth_backends = $rabbitmq::auth_backends $cluster_partition_handling = $rabbitmq::cluster_partition_handling $file_limit = $rabbitmq::file_limit $collect_statistics_interval = $rabbitmq::collect_statistics_interval $ipv6 = $rabbitmq::ipv6 $inetrc_config = $rabbitmq::inetrc_config $inetrc_config_path = $rabbitmq::inetrc_config_path $ssl_erl_dist = $rabbitmq::ssl_erl_dist $loopback_users = $rabbitmq::loopback_users if $ssl_only { $default_ssl_env_variables = {} } else { $default_ssl_env_variables = { 'NODE_PORT' => $port, 'NODE_IP_ADDRESS' => $node_ip_address, } } # This seems like a sensible default, and I think we have to assign it here # to be safe. Use $node_ip_address (which can also be undef) if # $management_ip_address is not set. if $rabbitmq::management_ip_address { $management_ip_address = $rabbitmq::management_ip_address } else { $management_ip_address = $rabbitmq::node_ip_address } - $inetrc_env = {'export ERL_INETRC' => $inetrc_config_path} + $inetrc_env = { 'export ERL_INETRC' => $inetrc_config_path } # Handle env variables. $_environment_variables = $default_ssl_env_variables + $inetrc_env + $rabbitmq::environment_variables if $ipv6 or $ssl_erl_dist { # must append "-proto_dist inet6_tcp" to any provided ERL_ARGS for # both the server and rabbitmqctl, being careful not to mess up # quoting. If both IPv6 and TLS are enabled, we must use "inet6_tls". # Finally, if only TLS is enabled (no IPv6), the -proto_dist value to use # is "inet_tls". if $ipv6 and $ssl_erl_dist { $proto_dist = 'inet6_tls' $ssl_path = " -pa ${::erl_ssl_path} " } elsif $ssl_erl_dist { $proto_dist = 'inet_tls' $ssl_path = " -pa ${::erl_ssl_path} " } else { $proto_dist = 'inet6_tcp' $ssl_path = '' } - $ipv6_or_tls_env = ['SERVER_ADDITIONAL', 'CTL'].reduce({}) |$memo, $item| { + $ipv6_or_tls_env = ['SERVER_ADDITIONAL', 'CTL'].reduce( {}) |$memo, $item| { $orig = $_environment_variables["RABBITMQ_${item}_ERL_ARGS"] $munged = $orig ? { # already quoted, keep quoting /^([\'\"])(.*)\1/ => "${1}${2}${ssl_path} -proto_dist ${proto_dist}${1}", # unset, add our own quoted value undef => "\"${ssl_path}-proto_dist ${proto_dist}\"", # previously unquoted value, add quoting default => "\"${orig}${ssl_path} -proto_dist ${proto_dist}\"", } - merge($memo, {"RABBITMQ_${item}_ERL_ARGS" => $munged}) + merge($memo, { "RABBITMQ_${item}_ERL_ARGS" => $munged }) } $environment_variables = $_environment_variables + $ipv6_or_tls_env } else { $environment_variables = $_environment_variables } file { '/etc/rabbitmq': ensure => directory, owner => $rabbitmq_user, group => $rabbitmq_group, mode => '2755', } file { '/etc/rabbitmq/ssl': ensure => directory, owner => $rabbitmq_user, group => $rabbitmq_group, mode => '2750', } file { 'rabbitmq.config': ensure => file, path => $config_path, content => template($config), owner => $rabbitmq_user, group => $rabbitmq_group, mode => '0640', } file { 'rabbitmq-env.config': ensure => file, path => $env_config_path, content => template($env_config), owner => $rabbitmq_user, group => $rabbitmq_group, mode => '0640', } file { 'rabbitmq-inetrc': ensure => file, path => $inetrc_config_path, content => template($inetrc_config), owner => $rabbitmq_user, group => $rabbitmq_group, mode => '0640', } if $use_config_file_for_plugins { file { 'enabled_plugins': ensure => file, path => '/etc/rabbitmq/enabled_plugins', content => template('rabbitmq/enabled_plugins.erb'), owner => $rabbitmq_user, group => $rabbitmq_group, mode => '0640', require => File['/etc/rabbitmq'], } } if $admin_enable { file { 'rabbitmqadmin.conf': ensure => file, path => '/etc/rabbitmq/rabbitmqadmin.conf', content => template('rabbitmq/rabbitmqadmin.conf.erb'), owner => $rabbitmq_user, group => $rabbitmq_group, mode => '0640', require => File['/etc/rabbitmq'], } } case $facts['os']['family'] { 'Debian': { file { '/etc/default/rabbitmq-server': ensure => file, content => template('rabbitmq/default.erb'), mode => '0644', owner => '0', group => '0', } } 'RedHat': { file { '/etc/security/limits.d/rabbitmq-server.conf': content => template('rabbitmq/limits.conf'), owner => '0', group => '0', mode => '0644', } } - default: { } + default: {} } if $facts['systemd'] { # systemd fact provided by systemd module systemd::service_limits { "${service_name}.service": - limits => {'LimitNOFILE' => $file_limit}, + limits => { 'LimitNOFILE' => $file_limit }, # The service will be notified when config changes restart_service => false, } } if $erlang_cookie == undef and $config_cluster { fail('You must set the $erlang_cookie value in order to configure clustering.') } elsif $erlang_cookie != undef { rabbitmq_erlang_cookie { "${rabbitmq_home}/.erlang.cookie": content => $erlang_cookie, force => $wipe_db_on_cookie_change, rabbitmq_user => $rabbitmq_user, rabbitmq_group => $rabbitmq_group, rabbitmq_home => $rabbitmq_home, service_name => $service_name, before => File['rabbitmq.config'], } } } diff --git a/manifests/init.pp b/manifests/init.pp index 72f08f7..3df75f4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,502 +1,500 @@ # # @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/rabbitmq/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_management_cacert # SSL management cacert. If unset set to ssl_cacert for backwards compatibility. # @param ssl_management_cert # SSL management cert. If unset set to ssl_cert for backwards compatibility. # @param ssl_management_key # SSL management key. If unset set to ssl_key for backwards compatibility. # @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, using either the Erlang or OpenSSL styles. # 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/mozilla/cipherscan # * Erlang style: `['ecdhe_rsa,aes_256_cbc,sha', 'dhe_rsa,aes_256_cbc,sha']` # * OpenSSL style: `['ECDHE-RSA-AES256-SHA', 'DHE-RSA-AES256-SHA']` # @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( +class rabbitmq ( 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 = 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 = '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 = 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 = '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 = 5671, Optional[String] $ssl_interface = undef, Integer[1, 65535] $ssl_management_port = 15671, Optional[Stdlib::Absolutepath] $ssl_management_cacert = $ssl_cacert, Optional[Stdlib::Absolutepath] $ssl_management_cert = $ssl_cert, Optional[Stdlib::Absolutepath] $ssl_management_key = $ssl_key, 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 = true, Boolean $ssl_reuse_sessions = true, Boolean $ssl_honor_cipher_order = true, Optional[Stdlib::Absolutepath] $ssl_dhfile = undef, 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 = 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 { + 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.pp b/manifests/install.pp index b172ba1..651799f 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,24 +1,23 @@ # Ensures that rabbitmq-server exists # # @api private class rabbitmq::install { - $package_ensure = $rabbitmq::package_ensure $package_name = $rabbitmq::package_name $rabbitmq_group = $rabbitmq::rabbitmq_group package { $package_name: ensure => $package_ensure, notify => Class['rabbitmq::service'], } if $rabbitmq::environment_variables['MNESIA_BASE'] { file { $rabbitmq::environment_variables['MNESIA_BASE']: ensure => 'directory', owner => 'root', group => $rabbitmq_group, mode => '0775', require => Package[$package_name], } } } diff --git a/manifests/install/rabbitmqadmin.pp b/manifests/install/rabbitmqadmin.pp index 9a29988..1a7ab3e 100644 --- a/manifests/install/rabbitmqadmin.pp +++ b/manifests/install/rabbitmqadmin.pp @@ -1,69 +1,67 @@ # Install rabbitmq admin # # @api private class rabbitmq::install::rabbitmqadmin { - if $rabbitmq::rabbitmqadmin_package { - package{'rabbitmqadmin': + package { 'rabbitmqadmin': ensure => 'present', name => $rabbitmq::rabbitmqadmin_package, } } else { - $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 $sanitized_ip = '127.0.0.1' } elsif $management_ip_address =~ Stdlib::Compat::Ipv6 { $sanitized_ip = join(enclose_ipv6(any2array($management_ip_address)), ',') } else { $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/management.pp b/manifests/management.pp index 3467c74..ad49da3 100644 --- a/manifests/management.pp +++ b/manifests/management.pp @@ -1,15 +1,13 @@ # Manage presence / absence of user resource for guest management user. # # @api private class rabbitmq::management { - $delete_guest_user = $rabbitmq::delete_guest_user if $delete_guest_user { - rabbitmq_user{ 'guest': + rabbitmq_user { 'guest': ensure => absent, provider => 'rabbitmqctl', } } - } diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 66fbdd0..97de0bc 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -1,39 +1,38 @@ # requires # puppetlabs-apt # puppetlabs-stdlib # # @api private -class rabbitmq::repo::apt( +class rabbitmq::repo::apt ( String $location = 'https://packagecloud.io/rabbitmq/rabbitmq-server', String $repos = 'main', Boolean $include_src = false, String $key = '8C695B0219AFDEB04A058ED8F4E789204D206F89', String $key_source = $rabbitmq::package_gpg_key, Optional[String] $key_content = $rabbitmq::key_content, Optional[String] $architecture = undef, - ) { - +) { $osname = downcase($facts['os']['name']) $pin = $rabbitmq::package_apt_pin apt::source { 'rabbitmq': ensure => present, location => "${location}/${osname}", repos => $repos, include => { 'src' => $include_src }, key => { 'id' => $key, 'source' => $key_source, 'content' => $key_content, }, architecture => $architecture, } if $pin { apt::pin { 'rabbitmq': packages => '*', priority => $pin, origin => inline_template('<%= require \'uri\'; URI(@location).host %>'), } } } diff --git a/manifests/repo/rhel.pp b/manifests/repo/rhel.pp index 1d6698e..5000df3 100644 --- a/manifests/repo/rhel.pp +++ b/manifests/repo/rhel.pp @@ -1,24 +1,23 @@ # Makes sure that the Packagecloud repo is installed # # @api private -class rabbitmq::repo::rhel( - $location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch", - String $key_source = $rabbitmq::package_gpg_key, - ) { - +class rabbitmq::repo::rhel ( + $location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch", + String $key_source = $rabbitmq::package_gpg_key, +) { yumrepo { 'rabbitmq': ensure => present, name => 'rabbitmq_rabbitmq-server', baseurl => $location, gpgkey => $key_source, enabled => 1, gpgcheck => 1, } # This may still be needed to prevent warnings # packagecloud key is gpg-pubkey-d59097ab-52d46e88 exec { "rpm --import ${key_source}": path => ['/bin','/usr/bin','/sbin','/usr/sbin'], unless => 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null', } } diff --git a/manifests/service.pp b/manifests/service.pp index f226007..f75f107 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,32 +1,30 @@ # This class manages the rabbitmq server service itself. # # @api private -class rabbitmq::service( +class rabbitmq::service ( Enum['running', 'stopped'] $service_ensure = $rabbitmq::service_ensure, Boolean $service_manage = $rabbitmq::service_manage, $service_name = $rabbitmq::service_name, ) inherits rabbitmq { - 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, } if $facts['systemd'] { Class['systemd::systemctl::daemon_reload'] -> Service['rabbitmq-server'] } } - } diff --git a/spec/acceptance/parameter_spec.rb b/spec/acceptance/parameter_spec.rb index a2bcdd9..85d31c6 100644 --- a/spec/acceptance/parameter_spec.rb +++ b/spec/acceptance/parameter_spec.rb @@ -1,48 +1,46 @@ require 'spec_helper_acceptance' describe 'rabbitmq parameter on a vhost:' do context 'create parameter resource' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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_plugin { [ 'rabbitmq_federation_management', 'rabbitmq_federation' ]: ensure => present } ~> Service['rabbitmq-server'] rabbitmq_vhost { 'fedhost': ensure => present, } -> rabbitmq_parameter { 'documentumFed@fedhost': component_name => 'federation-upstream', value => { 'uri' => 'amqp://server', 'expires' => '3600000', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - - # rubocop:disable RSpec/MultipleExpectations it 'has the parameter' do shell('rabbitmqctl list_parameters -p fedhost') do |r| expect(r.stdout).to match(%r{federation-upstream.*documentumFed.*expires.*3600000}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end end diff --git a/spec/acceptance/policy_spec.rb b/spec/acceptance/policy_spec.rb index 91161a4..f13af54 100644 --- a/spec/acceptance/policy_spec.rb +++ b/spec/acceptance/policy_spec.rb @@ -1,60 +1,58 @@ require 'spec_helper_acceptance' describe 'rabbitmq policy on a vhost:' do context 'create policy resource' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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', }, } rabbitmq_policy { 'eu-federation@myhost': pattern => '^eu\\.', priority => 0, applyto => 'all', definition => { 'federation-upstream-set' => 'all', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) # Apply twice to ensure no changes the second time. apply_manifest(pp, catch_failures: true) expect(apply_manifest(pp, catch_changes: true).exit_code).to be_zero end - - # rubocop:disable RSpec/MultipleExpectations it 'has the policy' do shell('rabbitmqctl list_policies -p myhost') do |r| expect(r.stdout).to match(%r{myhost.*ha-all.*ha-sync-mode}) expect(r.stdout).to match(%r{myhost.*eu-federation}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end end diff --git a/spec/acceptance/queue_spec.rb b/spec/acceptance/queue_spec.rb index a5ed1d1..0cb4f16 100644 --- a/spec/acceptance/queue_spec.rb +++ b/spec/acceptance/queue_spec.rb @@ -1,246 +1,240 @@ require 'spec_helper_acceptance' describe 'rabbitmq binding:' do context 'create binding and queue resources when using default management port' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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', tags => ['monitoring', 'tag1'], } -> rabbitmq_user_permissions { 'dan@host1': configure_permission => '.*', read_permission => '.*', write_permission => '.*', } rabbitmq_vhost { 'host1': ensure => present, } -> rabbitmq_exchange { 'exchange1@host1': user => 'dan', password => 'bar', type => 'topic', ensure => present, } -> rabbitmq_queue { 'queue1@host1': user => 'dan', password => 'bar', durable => true, auto_delete => false, ensure => present, } -> rabbitmq_binding { 'exchange1@queue1@host1': user => 'dan', password => 'bar', destination_type => 'queue', routing_key => '#', ensure => present, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - - # rubocop:disable RSpec/MultipleExpectations it 'has the binding' do shell('rabbitmqctl list_bindings -q -p host1') do |r| expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\s#}) expect(r.exit_code).to be_zero end end it 'has the queue' do shell('rabbitmqctl list_queues -q -p host1') do |r| expect(r.stdout).to match(%r{queue1}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end context 'create multiple bindings when same source / destination / vhost but different routing keys' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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', tags => ['monitoring', 'tag1'], } -> rabbitmq_user_permissions { 'dan@host1': configure_permission => '.*', read_permission => '.*', write_permission => '.*', } rabbitmq_vhost { 'host1': ensure => present, } -> rabbitmq_exchange { 'exchange1@host1': user => 'dan', password => 'bar', type => 'topic', ensure => present, } -> rabbitmq_queue { 'queue1@host1': user => 'dan', password => 'bar', durable => true, auto_delete => false, ensure => present, } -> rabbitmq_binding { 'binding 1': source => 'exchange1', destination => 'queue1', user => 'dan', vhost => 'host1', password => 'bar', destination_type => 'queue', routing_key => 'test1', ensure => present, } -> rabbitmq_binding { 'binding 2': source => 'exchange1', destination => 'queue1', user => 'dan', vhost => 'host1', password => 'bar', destination_type => 'queue', routing_key => 'test2', ensure => present, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - - # rubocop:disable RSpec/MultipleExpectations it 'has the bindings' do shell('rabbitmqctl list_bindings -q -p host1') do |r| expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest1}) expect(r.stdout).to match(%r{exchange1\sexchange\squeue1\squeue\stest2}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations it 'puppet resource shows a binding' do shell('puppet resource rabbitmq_binding') do |r| expect(r.stdout).to match(%r{source\s+=>\s+'exchange1',}) end end end context 'create binding and queue resources when using a non-default management port' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == 'RedHat' { class { 'erlang': epel_enable => true } Class['erlang'] -> Class['rabbitmq'] } class { 'rabbitmq': service_manage => true, port => 5672, management_port => 11111, delete_guest_user => true, admin_enable => true, } -> rabbitmq_user { 'dan': admin => true, password => 'bar', tags => ['monitoring', 'tag1'], } -> rabbitmq_user_permissions { 'dan@host2': configure_permission => '.*', read_permission => '.*', write_permission => '.*', } rabbitmq_vhost { 'host2': ensure => present, } -> rabbitmq_exchange { 'exchange2@host2': user => 'dan', password => 'bar', type => 'topic', ensure => present, } -> rabbitmq_queue { 'queue2@host2': user => 'dan', password => 'bar', durable => true, auto_delete => false, ensure => present, } -> rabbitmq_binding { 'exchange2@queue2@host2': user => 'dan', password => 'bar', destination_type => 'queue', routing_key => '#', ensure => present, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - - # rubocop:disable RSpec/MultipleExpectations it 'has the binding' do shell('rabbitmqctl list_bindings -q -p host2') do |r| expect(r.stdout).to match(%r{exchange2\sexchange\squeue2\squeue\s#}) expect(r.exit_code).to be_zero end end it 'has the queue' do shell('rabbitmqctl list_queues -q -p host2') do |r| expect(r.stdout).to match(%r{queue2}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end end diff --git a/spec/acceptance/user_spec.rb b/spec/acceptance/user_spec.rb index beff492..7b8e245 100644 --- a/spec/acceptance/user_spec.rb +++ b/spec/acceptance/user_spec.rb @@ -1,56 +1,54 @@ require 'spec_helper_acceptance' describe 'rabbitmq user:' do context 'create user resource' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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 - - # rubocop:disable RSpec/MultipleExpectations it 'has the user' do shell('rabbitmqctl list_users -q') do |r| expect(r.stdout).to match(%r{dan.*administrator}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end context 'destroy user resource' do it 'runs successfully' do pp = <<-EOS rabbitmq_user { 'dan': ensure => absent, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end it 'does not have the user' do shell('rabbitmqctl list_users -q') do |r| expect(r.stdout).not_to match(%r{dan\s+}) end end end end diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb index fc3722a..16a63d8 100644 --- a/spec/acceptance/vhost_spec.rb +++ b/spec/acceptance/vhost_spec.rb @@ -1,36 +1,34 @@ require 'spec_helper_acceptance' describe 'rabbitmq vhost:' do context 'create vhost resource' do it 'runs successfully' do pp = <<-EOS if $facts['os']['family'] == '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 - - # rubocop:disable RSpec/MultipleExpectations it 'has the vhost' do shell('rabbitmqctl list_vhosts') do |r| expect(r.stdout).to match(%r{myhost}) expect(r.exit_code).to be_zero end end # rubocop:enable RSpec/MultipleExpectations end end diff --git a/spec/unit/puppet/provider/rabbitmq_binding/rabbitmqadmin_spec.rb b/spec/unit/puppet/provider/rabbitmq_binding/rabbitmqadmin_spec.rb index 64fa586..26b5e28 100644 --- a/spec/unit/puppet/provider/rabbitmq_binding/rabbitmqadmin_spec.rb +++ b/spec/unit/puppet/provider/rabbitmq_binding/rabbitmqadmin_spec.rb @@ -1,187 +1,184 @@ require 'spec_helper' provider_class = Puppet::Type.type(:rabbitmq_binding).provider(:rabbitmqadmin) describe provider_class do let(:resource) do Puppet::Type::Rabbitmq_binding.new( name: 'source@target@/', destination_type: :queue, routing_key: 'blablub', arguments: {} ) end let(:provider) { provider_class.new(resource) } - # rubocop:disable RSpec/MultipleExpectations describe '#instances' do it 'returns instances' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with( 'bindings', '-p', '/', 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments' ).returns <<-EOT exchange\tdst_queue\tqueue\t*\t[] EOT instances = provider_class.instances expect(instances.size).to eq(1) expect(instances.map do |prov| { source: prov.get(:source), destination: prov.get(:destination), vhost: prov.get(:vhost), routing_key: prov.get(:routing_key) } end).to eq([ { source: 'exchange', destination: 'dst_queue', vhost: '/', routing_key: '*' } ]) end # rubocop:enable RSpec/MultipleExpectations - - # rubocop:disable RSpec/MultipleExpectations it 'returns multiple instances' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with( 'bindings', '-p', '/', 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments' ).returns <<-EOT exchange\tdst_queue\tqueue\trouting_one\t[] exchange\tdst_queue\tqueue\trouting_two\t[] EOT instances = provider_class.instances expect(instances.size).to eq(2) expect(instances.map do |prov| { source: prov.get(:source), destination: prov.get(:destination), vhost: prov.get(:vhost), routing_key: prov.get(:routing_key) } end).to eq([ { source: 'exchange', destination: 'dst_queue', vhost: '/', routing_key: 'routing_one' }, { source: 'exchange', destination: 'dst_queue', vhost: '/', routing_key: 'routing_two' } ]) end end # rubocop:enable RSpec/MultipleExpectations describe 'Test for prefetch error' do let(:resource) do Puppet::Type::Rabbitmq_binding.new( name: 'binding1', source: 'exchange1', destination: 'destqueue', destination_type: :queue, routing_key: 'blablubd', arguments: {} ) end it 'exists' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with( 'bindings', '-p', '/', 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments' ).returns <<-EOT exchange\tdst_queue\tqueue\t*\t[] EOT provider_class.prefetch({}) end it 'matches' do # Test resource to match against provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with( 'bindings', '-p', '/', 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments' ).returns <<-EOT exchange\tdst_queue\tqueue\t*\t[] EOT provider_class.prefetch('binding1' => resource) end end describe '#create' do it 'calls rabbitmqadmin to create' do provider.expects(:rabbitmqadmin).with( 'declare', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination=target', 'arguments={}', 'routing_key=blablub', 'destination_type=queue' ) provider.create end context 'specifying credentials' do let(:resource) do Puppet::Type::Rabbitmq_binding.new( name: 'source@test2@/', destination_type: :queue, routing_key: 'blablubd', arguments: {}, user: 'colin', password: 'secret' ) end let(:provider) { provider_class.new(resource) } it 'calls rabbitmqadmin to create' do provider.expects(:rabbitmqadmin).with( 'declare', 'binding', '--vhost=/', '--user=colin', '--password=secret', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination=test2', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue' ) provider.create end end context 'new queue_bindings' do let(:resource) do Puppet::Type::Rabbitmq_binding.new( name: 'binding1', source: 'exchange1', destination: 'destqueue', destination_type: :queue, routing_key: 'blablubd', arguments: {} ) end let(:provider) { provider_class.new(resource) } it 'calls rabbitmqadmin to create' do provider.expects(:rabbitmqadmin).with( 'declare', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=exchange1', 'destination=destqueue', 'arguments={}', 'routing_key=blablubd', 'destination_type=queue' ) provider.create end end end describe '#destroy' do it 'calls rabbitmqadmin to destroy' do provider.expects(:rabbitmqadmin).with( 'delete', 'binding', '--vhost=/', '--user=guest', '--password=guest', '-c', '/etc/rabbitmq/rabbitmqadmin.conf', 'source=source', 'destination_type=queue', 'destination=target', 'properties_key=blablub' ) provider.destroy end end end diff --git a/spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb b/spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb index cee25f6..609e6e3 100644 --- a/spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb +++ b/spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb @@ -1,193 +1,189 @@ require 'spec_helper' provider_class = Puppet::Type.type(:rabbitmq_parameter).provider(:rabbitmqctl) describe provider_class do let(:resource) do Puppet::Type.type(:rabbitmq_parameter).new( name: 'documentumShovel@/', component_name: 'shovel', value: { 'src-uri' => 'amqp://', 'src-queue' => 'my-queue', 'dest-uri' => 'amqp://remote-server', 'dest-queue' => 'another-queue' } ) end let(:provider) { provider_class.new(resource) } after do described_class.instance_variable_set(:@parameters, nil) end describe '#prefetch' do it 'exists' do expect(described_class).to respond_to :prefetch end it 'matches' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns <<-EOT shovel documentumShovel {"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"} EOT provider_class.prefetch('documentumShovel@/' => resource) end end describe '#instances' do it 'exists' do expect(described_class).to respond_to :instances end it 'fail with invalid output from list' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider.class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns 'foobar' expect { provider_class.instances }.to raise_error Puppet::Error, %r{cannot parse line from list_parameter} end it 'return no instance' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns '' instances = provider_class.instances expect(instances.size).to eq(0) end - - # rubocop:disable RSpec/MultipleExpectations it 'return one instance' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns <<-EOT shovel documentumShovel {"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"} EOT instances = provider_class.instances expect(instances.size).to eq(1) expect(instances.map do |prov| { name: prov.get(:name), component_name: prov.get(:component_name), value: prov.get(:value) } end).to eq( [ { name: 'documentumShovel@/', component_name: 'shovel', value: { 'src-uri' => 'amqp://', 'src-queue' => 'my-queue', 'dest-uri' => 'amqp://remote-server', 'dest-queue' => 'another-queue' } } ] ) end # rubocop:enable RSpec/MultipleExpectations - - # rubocop:disable RSpec/MultipleExpectations it 'return multiple instances' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns <<-EOT shovel documentumShovel1 {"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"} shovel documentumShovel2 {"src-uri":["amqp://cl1","amqp://cl2"],"src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"} EOT instances = provider_class.instances expect(instances.size).to eq(2) expect(instances.map do |prov| { name: prov.get(:name), component_name: prov.get(:component_name), value: prov.get(:value) } end).to eq( [ { name: 'documentumShovel1@/', component_name: 'shovel', value: { 'src-uri' => 'amqp://', 'src-queue' => 'my-queue', 'dest-uri' => 'amqp://remote-server', 'dest-queue' => 'another-queue' } }, { name: 'documentumShovel2@/', component_name: 'shovel', value: { 'src-uri' => ['amqp://cl1', 'amqp://cl2'], 'src-queue' => 'my-queue', 'dest-uri' => 'amqp://remote-server', 'dest-queue' => 'another-queue' } } ] ) end it 'return different instances' do provider_class.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT / EOT provider_class.expects(:rabbitmqctl_list).with('parameters', '-p', '/').returns <<-EOT shovel documentumShovel1 {"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"} federation documentumFederation2 {"uri":"amqp://","expires":"360000"} EOT instances = provider_class.instances expect(instances.size).to eq(2) expect(instances.map do |prov| { name: prov.get(:name), component_name: prov.get(:component_name), value: prov.get(:value) } end).to eq( [ { name: 'documentumShovel1@/', component_name: 'shovel', value: { 'src-uri' => 'amqp://', 'src-queue' => 'my-queue', 'dest-uri' => 'amqp://remote-server', 'dest-queue' => 'another-queue' } }, { name: 'documentumFederation2@/', component_name: 'federation', value: { 'uri' => 'amqp://', 'expires' => '360000' } } ] ) end # rubocop:enable RSpec/MultipleExpectations end describe '#create' do it 'create parameter' do provider.expects(:rabbitmqctl).with('set_parameter', '-p', '/', 'shovel', 'documentumShovel', '{"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"}') provider.create end end describe '#destroy' do it 'destroy parameter' do provider.expects(:rabbitmqctl).with('clear_parameter', '-p', '/', 'shovel', 'documentumShovel') provider.destroy end end end diff --git a/spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb b/spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb index b6951c4..ae98520 100644 --- a/spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb +++ b/spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb @@ -1,57 +1,56 @@ require 'spec_helper' describe Puppet::Type.type(:rabbitmq_user_permissions) do let(:perms) do Puppet::Type.type(:rabbitmq_user_permissions).new(name: 'foo@bar') end it 'accepts a valid hostname name' do perms[:name] = 'dan@bar' expect(perms[:name]).to eq('dan@bar') end it 'requires a name' do expect do Puppet::Type.type(:rabbitmq_user_permissions).new({}) end.to raise_error(Puppet::Error, 'Title or name must be provided') end it 'fails when names dont have a @' do expect do perms[:name] = 'bar' end.to raise_error(Puppet::Error, %r{Valid values match}) end [:configure_permission, :read_permission, :write_permission].each do |param| it 'does not default to anything' do expect(perms[param]).to eq(nil) end it "should accept a valid regex for #{param}" do perms[param] = '.*?' expect(perms[param]).to eq('.*?') end it "should accept an empty string for #{param}" do perms[param] = '' expect(perms[param]).to eq('') end it "should not accept invalid regex for #{param}" do expect do perms[param] = '*' end.to raise_error(Puppet::Error, %r{Invalid regexp}) end end - # rubocop:disable RSpec/MultipleExpectations { rabbitmq_vhost: 'dan@test', rabbitmq_user: 'test@dan' }.each do |k, v| it "should autorequire #{k}" do vhost = if k == :rabbitmq_vhost Puppet::Type.type(k).new(name: 'test') else Puppet::Type.type(k).new(name: 'test', password: 'pass') end perm = Puppet::Type.type(:rabbitmq_user_permissions).new(name: v) Puppet::Resource::Catalog.new :testing do |conf| [vhost, perm].each { |resource| conf.add_resource resource } end rel = perm.autorequire[0] expect(rel.source.ref).to eq(vhost.ref) expect(rel.target.ref).to eq(perm.ref) end end # rubocop:enable RSpec/MultipleExpectations end