diff --git a/README.md b/README.md index 2176a6a90..1ccabf4b0 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ RabbitMQ Environment Variables in rabbitmq_env.config ####`erlang_cookie` The erlang cookie to use for clustering - must be the same between all nodes. +This value has no default and must be set explicitly if using clustering. ###`key_content` diff --git a/lib/puppet/type/rabbitmq_erlang_cookie.rb b/lib/puppet/type/rabbitmq_erlang_cookie.rb index fc56575a9..564af5253 100644 --- a/lib/puppet/type/rabbitmq_erlang_cookie.rb +++ b/lib/puppet/type/rabbitmq_erlang_cookie.rb @@ -3,20 +3,6 @@ newparam(:path, :namevar => true) - validate do - # This does pre-validation on the content property and force parameter. - # The intent is to simulate the prior behavior to the invention of this - # type (see https://github.com/puppetlabs/puppetlabs-rabbitmq/blob/4.1.0/manifests/config.pp#L87-L117) - # where validation occurs before the catalog starts being applied. - # This prevents other resources from failing after attempting to apply - # this resource and having it fail due to the force parameter being - # set to false. - is = (File.read(self[:path]) if File.exists?(self[:path])) || '' - should = self[:content] - failstring = 'The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this tohappen automatically.' - fail(failstring) if (is != should && self[:force] != :true) - end - newproperty(:content) do desc 'Content of cookie' newvalues(/^\S+$/) diff --git a/manifests/config.pp b/manifests/config.pp index 3f65bb5f7..95b7ab213 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -97,7 +97,6 @@ require => File['/etc/rabbitmq'], } - if $config_cluster { if $erlang_cookie == undef { diff --git a/manifests/params.pp b/manifests/params.pp index 40d50c9e6..219a41e93 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -59,7 +59,7 @@ $delete_guest_user = false $env_config = 'rabbitmq/rabbitmq-env.conf.erb' $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf' - $erlang_cookie = 'EOKOWXQREETZSHFNTPEY' + $erlang_cookie = undef $node_ip_address = 'UNSET' $plugin_dir = "/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins" $port = '5672' diff --git a/spec/unit/puppet/type/rabbitmq_erlang_cookie_spec.rb b/spec/unit/puppet/type/rabbitmq_erlang_cookie_spec.rb deleted file mode 100644 index c35548351..000000000 --- a/spec/unit/puppet/type/rabbitmq_erlang_cookie_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'mocha' -require 'puppet' -require 'puppet/type/rabbitmq_exchange' -RSpec.configure do |config| - config.mock_with :mocha -end -describe Puppet::Type.type(:rabbitmq_erlang_cookie) do - context 'when content needs to change and force is unset' do - it 'fails' do - File.expects(:read).with('/var/lib/rabbitmq/.erlang.cookie').returns('OLDCOOKIE') - File.expects(:exists?).returns(true) - expect { - Puppet::Type.type(:rabbitmq_erlang_cookie).new( - :name => '/var/lib/rabbitmq/.erlang.cookie', - :content => 'NEWCOOKIE', - ) - }.to raise_error(Puppet::Error, /The current erlang cookie needs to change/) - end - end - - context 'when content needs to change and force is true' do - it 'sets the cookie' do - File.expects(:read).with('/var/lib/rabbitmq/.erlang.cookie').returns('OLDCOOKIE') - File.expects(:exists?).returns(true) - cookie = Puppet::Type.type(:rabbitmq_erlang_cookie).new( - :name => '/var/lib/rabbitmq/.erlang.cookie', - :content => 'NEWCOOKIE', - :force => true, - ) - expect(cookie[:content]).to eq('NEWCOOKIE') - end - end - - context 'when content does not need to change' do - it 'still sets the cookie' do - File.expects(:read).with('/var/lib/rabbitmq/.erlang.cookie').returns('NEWCOOKIE') - File.expects(:exists?).returns(true) - cookie = Puppet::Type.type(:rabbitmq_erlang_cookie).new( - :name => '/var/lib/rabbitmq/.erlang.cookie', - :content => 'NEWCOOKIE', - ) - expect(cookie[:content]).to eq('NEWCOOKIE') - end - end -end