Member-only story
Remove user account — Ansible module user
How to remove an example user removing home directory and spool files.
How to remove a user account with Ansible?
I’m going to show you a live demo with some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible remove user account
Today we’re talking about the Ansible module `user`.
The full name is `ansible.builtin.user`, which means that is part of the collection of modules “builtin” with ansible and shipped with it.
It’s a module pretty stable and out for years, it manages user accounts.
It supports a huge variety of Linux distributions, SunOS and macOS, and FreeBSD.
This module uses Linux distributions `userdel` to delete, on FreeBSD, this module uses `pw userdel`, on macOS, this module uses `dscl`.
For Windows, use the `ansible.windows.win_user` module instead.
Main Parameters
- name string — username
- state string — present/absent