This is a reverse of the previous post.
Reference: https://docs.ansible.com/ansible/latest/modules/user_module.html
YAML file
--- - hosts: linux become: true become_user: root tasks: - name: Delete user, same as userdel -r user: name: unixadm remove: yes state: absent ...
Execution
The execution is ansible-playbook lab3.yaml -K
where -K
is to prompt for the sudo password.
Result