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
答案 0 :(得分:1)
Salt有模块列出所有用户或获取用户信息
您可以按照 groups post
中的相同方式使用它对于列出远程系统中用户的模块,请参阅:
答案 1 :(得分:0)
您可以查看用户是否' foo'存在以下代码:
{% set all_users = salt['user.list_users']() %}
{% if 'foo' in all_users %}
do something
{% endif %}