ansible.builtin.group – Add or remove groups

Note

This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name group even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.

New in version 0.0.2: of ansible.builtin

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • groupadd

  • groupdel

  • groupmod

Parameters

Parameter Choices/Defaults Comments
gid
integer
Optional GID to set for the group.
local
boolean
added in 2.6 of ansible.builtin
    Choices:
  • no ←
  • yes
Forces the use of "local" command alternatives on platforms that implement it.
This is useful in environments that use centralized authentication when you want to manipulate the local groups. (e.g. it uses lgroupadd instead of groupadd).
This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
name
string / required
Name of the group to manage.
non_unique
boolean
added in 2.8 of ansible.builtin
    Choices:
  • no ←
  • yes
This option allows to change the group ID to a non-unique value. Requires gid.
Not supported on macOS or BusyBox distributions.
state
string
    Choices:
  • absent
  • present ←
Whether the group should be present or not on the remote host.
system
boolean
    Choices:
  • no ←
  • yes
If yes, indicates that the group created is a system group.

See Also

See also

ansible.builtin.user

The official documentation on the ansible.builtin.user module.

ansible.windows.win_group

The official documentation on the ansible.windows.win_group module.

Examples

- name: Ensure group "somegroup" exists
  group:
    name: somegroup
    state: present

- name: Ensure group "docker" exists with correct gid
  group:
    name: docker
    state: present
    gid: 1750

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
gid
integer
When state is 'present'
Group ID of the group.

Sample:
1001
name
string
always
Group name

Sample:
users
state
string
always
Whether the group is present or not

Sample:
absent
system
boolean
When state is 'present'
Whether the group is a system group or not



Authors

  • Stephen Fromm (@sfromm)