Cross posting this from Ask@PuppetLabs. (There simply isn't enough traffic there.)
I've seen a number of examples for adding users to %wheel with Augeas. These are all variations of the same thing; inserting a user node at the end.
- Quick Tip: Add users to a group with augeas
- How to manage configurations in Linux with Puppet and Augeas
- Puppet Group Management Module
What I need to do is also remove users that are added outside of configuration management. For Puppet to manage the group, only users defined in my Puppet class should be present and any others removed.
Seems like exec'ing a simple Sed command would be much easier, but so many people say to try to stay away from exec. Is it such a bad solution in this case?
Defining wheel users this way causes them to be added, but if you remove jane from the class, she will not be removed from the wheel group on the next Puppet run.
The only way I have found around this is to purge the wheel group and re-add them each time.
I considered an
onlyif
to match my defined users to prevent this from running on each Puppet run. However, this is also the only way to remove users added outside of Puppet to ensure that %wheel is managed solely by Puppet.This solution also doesn't lend well to parametrization for reuse.
It might be possible to use the Group members type to specifically set the members of the group. You may need to use the forcelocal option.