users-formula/users/profile.sls

30 lines
910 B
Plaintext
Raw Permalink Normal View History

2015-08-09 18:59:51 +02:00
{% from "users/map.jinja" import users with context %}
include:
- users
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
{%- set current = salt.user.info(name) -%}
2015-08-09 18:59:51 +02:00
{%- if user == None -%}
{%- set user = {} -%}
{%- endif -%}
{%- set home = user.get('home', current.get('home', "/home/%s" % name)) -%}
2015-08-09 18:59:51 +02:00
{%- set manage = user.get('manage_profile', False) -%}
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
{%- set user_group = user.prime_group.name -%}
{%- else -%}
{%- set user_group = name -%}
{%- endif %}
{%- if manage -%}
users_{{ name }}_user_profile:
file.managed:
- name: {{ home }}/.profile
- user: {{ name }}
- group: {{ user_group }}
- mode: '0644'
- template: jinja
2015-08-09 18:59:51 +02:00
- source:
- salt://users/files/profile/{{ name }}/profile
- salt://users/files/profile/profile
{% endif %}
{% endfor %}