Main » 2020 July 4 » Check if user exists with Ansible
8:57 PM Check if user exists with Ansible |
It is easy to detect if a user is registered on a Linux system with Ansible getent module. Example:
- name: Check if user exists Here we simply use user_name variable with whatever user we need to find. And the result goes to an auto-registered variable "getent_password". If the user we are looking for is not there, we get dictionary with null value. E.g. we were looking for user_name: super, then the debug output will look like this:
getent_passwd: |
|
Total comments: 0 | |