I've almost finished a pretty simple type/provider to manage
RabbitMQ users and virtual hosts.
I'm using the 'ensurable' keyword in my type to save a bit of boilerplate.
Type is below (the provider is just a wrapper around the 'rabbitmqctl'
command.
Have a feeling there's a developer guide somewhere I haven't found
(been working from the puppetlabs site and @kartars blog).
Couple of basic questions:
1. how can I set the type to default to 'ensure => present, isadmin =>
false' ?
Not sure if the ensurable mechanism is causing the first to be hard,
but I can't see a way to set defaults in general
2. is there a way to mark attributes as required?
I've provided a validation for the initial_password parameter, but it only
seems to fire if the parameter is there;
it doesn't get checked if the parameter is absent.
=======================================================
# cat lib/puppet/type/rabbitmq_user.rb
Puppet::Type.newtype(:rabbitmq_user) do
@doc = "Manage RabbitMQ users"
ensurable
newparam(:name) do
desc "The name of the user"
validate do |n|
raise ArgumentError, "cannot be empty" if n.empty?
raise ArgumentError, "can't contain spaces" if ( n =~ %r(\s+) )
resource[:provider] = :rabbitmq_user
end
isnamevar
end
newparam(:initial_password) do
desc "the password for the user - only set on creation time"
validate do |n|
raise ArgumentError, "cannot be empty" if (n.empty? or n.nil?)
resource[:provider] = :rabbitmq_user
end
end
end
===================================================
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.