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:
Hope this helps.