Reputation: 23
I'm writing a SaltStack state, and I need to know if a remote user exists to do or don't do something.
I need something like this:
{% if user foo exists %}
do something
{% endif %}
I've tried with user.present, user.absent, but nothing of this does what I need.
Someone have done this, but with remote groups: SaltStack: Do ... if group "foo" exists on remote-host
Is this possible? Thanks
Upvotes: 1
Views: 3712
Reputation: 2300
You can check if the user 'foo' exists with the following code:
{% set all_users = salt['user.list_users']() %}
{% if 'foo' in all_users %}
do something
{% endif %}
Upvotes: 2
Reputation: 170
Salt have module to list All users or to get User info
you can use it in the same way as they did in the groups post
for the module that lists user's in remote system please refer:
Upvotes: 1