group_by
Collection: builtin
Full Name: group_by
Aliases: ansible.builtin.group_by
Controller module — runs on the local controller, not on remote hosts.
Synopsis
Create inventory groups from a host expression during a play
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | yes | The variable expression to use for grouping. The result is used as the group name. | |
| parents | list | [all] | The list of parent groups to add the new group to. |
Example
- name: Group hosts by operating system family
group_by:
key: "os_{{ ansible_os_family | lower }}"