Saltstack Official Users Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
900B

  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. {%- set current = salt.user.info(name) -%}
  6. {%- if user == None -%}
  7. {%- set user = {} -%}
  8. {%- endif -%}
  9. {%- set home = user.get('home', current.get('home', "/home/%s" % name)) -%}
  10. {%- set manage = user.get('manage_bashrc', False) -%}
  11. {%- if 'prime_group' in user and 'name' in user['prime_group'] %}
  12. {%- set user_group = user.prime_group.name -%}
  13. {%- else -%}
  14. {%- set user_group = name -%}
  15. {%- endif %}
  16. {%- if manage -%}
  17. users_{{ name }}_user_bashrc:
  18. file.managed:
  19. - name: {{ home }}/.bashrc
  20. - user: {{ name }}
  21. - group: {{ user_group }}
  22. - mode: 644
  23. - template: jinja
  24. - source:
  25. - salt://users/files/bashrc/{{ name }}/bashrc
  26. - salt://users/files/bashrc/bashrc
  27. {% endif %}
  28. {% endfor %}