salt-states/common/users.sls

39 lines
1005 B
Plaintext
Raw Permalink Normal View History

2023-06-27 07:16:37 +00:00
{% for user, args in pillar['users'].items() %}
# remove users
{% if args['remove'] is defined %}
{{ user }}:
user.absent
{% if 'alias_target' in args %}
alias.present:
- target: {{ args['alias_target'] }}
{% endif %}
{% else %}
# add users
{{ user }}:
user.present:
- fullname: {{ args['fullname'] | default('') }}
- home: {{ args['home'] | default('/home/'+user) }}
- shell: {{ args['shell'] | default('/bin/bash') }}
{% if args['uid'] is defined %}
- uid: {{ args['uid'] }}
{% endif %}
- password: {{ args['password'] }}
- enforce_password: {{ args['enforce_password'] | default('True') }}
{% if 'groups' in args %}
- groups: {{ args['groups'] }}
{% endif %}
{% if 'alias_target' in args %}
alias.present:
- target: {{ args['alias_target'] }}
{% endif %}
{% if 'ssh_auth' in args %}
{{ user }}_autherized_keys:
ssh_auth:
- present
- user: {{ user }}
- names: {{ args['ssh_auth'] }}
{% endif %}
{% endif %}
{% endfor %}