diff --git a/content/reference/functions/getgroups.markdown b/content/reference/functions/getgroups.markdown new file mode 100644 index 000000000..4fc3153ba --- /dev/null +++ b/content/reference/functions/getgroups.markdown @@ -0,0 +1,47 @@ +--- +layout: default +title: getgroups +--- + +{{< CFEngine_function_prototype(exclude_names, exclude_ids) >}} + +**Description:** Returns a list of all groups defined, except those names in the comma separated string of `exclude_names` and the comma separated string of uids in `exclude_ids` + +{{< CFEngine_function_attributes(exclude_names, exclude_ids) >}} + +**Example:** + +```cf3 +bundle agent main +{ + vars: + "groups" + slist => getgroups("root", ""); + + "first_three_groups" + slist => sublist("@(groups)", head, 3); + + reports: + "$(first_three_groups)"; + +} +``` + +**Output:** + +``` +R: daemon +R: bin +R: sys +``` + +**Notes:** + +- This function is currently only available on Unix-like systems. +- This function will return both local and remote (for example, groups defined in an external directory like LDAP) groups on a system. + +**History:** + +- Introduced in CFEngine 3.27. + +**See also:** [`getgroupinfo()`][getgroupinfo].