X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Frabbitmq%2Flib%2Fpuppet%2Fprovider%2Frabbitmq_erlang_cookie%2Fruby.rb;fp=3rdparty%2Fmodules%2Frabbitmq%2Flib%2Fpuppet%2Fprovider%2Frabbitmq_erlang_cookie%2Fruby.rb;h=47dfdd348f90990b567569cf9f95ddc2b1dd9b38;hb=94a8783f522bbf2996cb8a59b977dea583e8b0c7;hp=58c8b3c96693bbfcb30b31a002c964e4fe297f9e;hpb=e107504bce7d9b21cc301124fc7c39fdb0762374;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb b/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb index 58c8b3c96..47dfdd348 100644 --- a/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb +++ b/3rdparty/modules/rabbitmq/lib/puppet/provider/rabbitmq_erlang_cookie/ruby.rb @@ -1,11 +1,7 @@ require 'puppet' require 'set' Puppet::Type.type(:rabbitmq_erlang_cookie).provide(:ruby) do - - defaultfor :feature => :posix - has_command(:puppet, 'puppet') do - environment :PATH => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' - end + confine feature: :posix def exists? # Hack to prevent the create method from being called. @@ -14,25 +10,22 @@ Puppet::Type.type(:rabbitmq_erlang_cookie).provide(:ruby) do end def content=(value) - if resource[:force] == :true # Danger! - puppet('resource', 'service', resource[:service_name], 'ensure=stopped') - FileUtils.rm_rf(resource[:rabbitmq_home] + File::PATH_SEPARATOR + 'mnesia') - File.open(resource[:path], 'w') do |cookie| - cookie.chmod(0400) - cookie.write(value) - end - FileUtils.chown(resource[:rabbitmq_user], resource[:rabbitmq_group], resource[:path]) - else - fail("The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this to happen automatically.") + raise('The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this to happen automatically.') unless resource[:force] == :true # Danger! + + Puppet::Type.type(:service).new(name: resource[:service_name]).provider.stop + FileUtils.rm_rf(resource[:rabbitmq_home] + File::SEPARATOR + 'mnesia') + File.open(resource[:path], 'w') do |cookie| + cookie.chmod(0o400) + cookie.write(value) end + FileUtils.chown(resource[:rabbitmq_user], resource[:rabbitmq_group], resource[:path]) end def content - if File.exists?(resource[:path]) + if File.exist?(resource[:path]) File.read(resource[:path]) else '' end end - end