If you are not familiar with modules, check out Ansible - Getting Started with Modules.
The group module is similar to the groupadd and groupdel commands. The user module is used to create or delete a group on a managed node (e.g. target system). In this example, group001 will be created.
- name: create group001
group:
name: group001
state: present
In this example, group001 will be deleted.
- name: delete group001
group:
name: group001
state: absent