This seems like it could easily be done with a replace_patterns promise.
Here's an untested edit_line bundle:
bundle edit_line remove_user_from_group (user,group) {
replace_patterns:
# This uses a zero width positive look behind assertion to make sure
# that the proper group is matched but is not part of the pattern
# being replaced.
"(?<=$(group).*)($(user))"
replace_with => value(""),
comment => "Remove user as only member";
"(?<=$(group).*)(,$(user))"
replace_with => value(""),
comment => "Remove user at end of list";
"(?<=$(group).*)($(user),)"
replace_with => value(""),
comment => "Remove user at beginning of list";
"(?<=$(group).*)(,$(user),)"
replace_with => value(","),
comment => "Remove user in middle of list";
}
I don't have time to test this right now, but if someone wants to give it a try, and it works, I'll open a pull request to add it to
cfengine_stdlib.cf.
--
Brian
> --
> You received this message because you are subscribed to the Google Groups "help-cfengine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
help-cfengin...@googlegroups.com.
> To post to this group, send email to
help-c...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/help-cfengine?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Brian