On Thu, Jan 5, 2012 at 10:50 AM, Andreas N <[email protected]> wrote:
> On Wednesday, January 4, 2012 3:06:27 PM UTC+1, Gonzalo wrote:
>>
>>
>> Otherwise, group membership is managed as a property of Users, ergo
>>> you cannot manage it (directly) if you do not manage the users in
>>> question. Your only options in that case are an Exec or a custom
>>> Group provider.
>>>
>>
>> Ah, ok. That confirms it then. I managed to create a define to do what I
>> want and it seems to work. Happy to share it if anyone is interested in it.
>>
>
> I'd be very interested in your solution, as I am in a similar situation.
>
Sure. Just a quick disclaimer, there may be better ways of doing this!! But
it works for me:
define groups::addlocalmembers (
$group,
$ensure='present'
) {
case $ensure {
'present': {
exec { "add_${name}_to_${group}":
command => "groupmems -g $group -a $name",
onlyif => [ "id $name" ],
unless => [ "groups $name | grep ' $group\\( \\|\$\\)'" ],
require => Group["$group"],
}
}
'absent': {
exec { "remove_${name}_to_${group}":
command => "groupmems -g $group -d $name",
onlyif => [ "groups $name | grep ' $group\\( \\|\$\\)'" ],
require => Group["$group"],
}
}
default: {
fail("Unknown ensure value: $ensure")
}
}
}
... so essentially I would call it like so:
groups::addlocalmembers { ["mysql", "user1", "user2"]: group =>
"local_group_here" }
Hope this helps.
- Gonzalo
--
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.