Saltstack Official Users Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
815B

  1. {% from "users/map.jinja" import users with context %}
  2. include:
  3. - users
  4. {% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
  5. {%- if user == None -%}
  6. {%- set user = {} -%}
  7. {%- endif -%}
  8. {%- set home = user.get('home', "/home/%s" % name) -%}
  9. {%- set manage = user.get('manage_bashrc', False) -%}
  10. {%- if 'prime_group' in user and 'name' in user['prime_group'] %}
  11. {%- set user_group = user.prime_group.name -%}
  12. {%- else -%}
  13. {%- set user_group = name -%}
  14. {%- endif %}
  15. {%- if manage -%}
  16. users_{{ name }}_user_bashrc:
  17. file.managed:
  18. - name: {{ home }}/.bashrc
  19. - user: {{ name }}
  20. - group: {{ user_group }}
  21. - mode: 644
  22. - source:
  23. - salt://users/files/bashrc/{{ name }}/bashrc
  24. - salt://users/files/bashrc/bashrc
  25. {% endif %}
  26. {% endfor %}