forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request redhat-openstack#282 from cmurphy/cookie
Replace erlang cookie fact with type and provider
- Loading branch information
Showing
9 changed files
with
114 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'puppet' | ||
require 'set' | ||
Puppet::Type.type(:rabbitmq_erlang_cookie).provide(:ruby) do | ||
|
||
defaultfor :feature => :posix | ||
has_command(:puppet, 'puppet') do | ||
environment :PATH => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' | ||
end | ||
|
||
def exists? | ||
# Hack to prevent the create method from being called. | ||
# We never need to create or destroy this resource, only change its value | ||
true | ||
end | ||
|
||
def content=(value) | ||
if resource[:force] == :true # Danger! | ||
puppet('resource', 'service', resource[:service_name], 'ensure=stopped') | ||
FileUtils.rm_rf('/var/lib/rabbitmq/mnesia') | ||
File.open(resource[:path], 'w') do |cookie| | ||
cookie.chmod(0400) | ||
cookie.write(value) | ||
end | ||
FileUtils.chown('rabbitmq', 'rabbitmq', resource[:path]) | ||
else | ||
fail("The current erlang cookie needs to change. In order to do this the RabbitMQ database needs to be wiped. Please set force => true to allow this to happen automatically.") | ||
end | ||
end | ||
|
||
def content | ||
if File.exists?(resource[:path]) | ||
File.read(resource[:path]) | ||
else | ||
'' | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Puppet::Type.newtype(:rabbitmq_erlang_cookie) do | ||
desc 'Type to manage the rabbitmq erlang cookie securely' | ||
|
||
newparam(:path, :namevar => true) | ||
|
||
newproperty(:content) do | ||
desc 'Content of cookie' | ||
newvalues(/^\S+$/) | ||
def change_to_s(current, desired) | ||
"The rabbitmq erlang cookie was changed" | ||
end | ||
end | ||
|
||
newparam(:force) do | ||
defaultto(:false) | ||
newvalues(:true, :false) | ||
end | ||
|
||
newparam(:service_name) do | ||
newvalues(/^\S+$/) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.