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
51 changes: 51 additions & 0 deletions content/reference/functions/findlocalgroups.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
layout: default
title: findlocalgroups
---

{{< CFEngine_function_prototype(filter) >}}

**Description:** Returns a data container of all local groups with their attributes that are matching a filter. If no filter is specified, it will return all the local groups.

{{< CFEngine_function_attributes(filter) >}}

The `filter` argument can be used to look up groups with specific attributes that match values. The filter is a `"data"` container array or `"slist"` comprised of pairs of attribute and value/regex pattern `{ "attribute1=value1", "attribute2=value2", ... }`.

The possible attributes are:

- `name`: name
- `gid`: group id
- `member` members: a list of users separated by commas

**Example:**

```cfengine3
bundle agent main
{
vars:
"filter" slist => { "name=root" };
"groups" data => findlocalgroups("@(filter)");

reports:
"$(with)" with => storejson("@(groups)");
}
```

Output:

```
R: {
"root": {
"gid": 0,
"members": []
}
}
```
Comment thread
victormlg marked this conversation as resolved.

**Notes:**

- This function is currently only available on Unix-like systems.

**History:**

- Function added in 3.27.0.