Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions content/reference/functions/getgroups.markdown
Original file line number Diff line number Diff line change
@@ -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
```
Comment thread
nickanderson marked this conversation as resolved.

**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].