Saltstack Official Users Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

46 lines
1.5KB

  1. {% from "users/map.jinja" import users with context -%}
  2. include:
  3. - users
  4. {% set userfile_dirs = salt['cp.list_master_dirs'](prefix='users/files/user/') -%}
  5. {%- for username, user in salt['pillar.get']('users', {}).items() if (user.absent is not defined or not user.absent) -%}
  6. {%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%}
  7. {%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%}
  8. {%- set user_home = salt['pillar.get'](('users:' ~ username ~ ':home'), '/home/' ~ username ) -%}
  9. {%- if user_files.enabled -%}
  10. {%- if user_files.source is defined -%}
  11. {%- if user_files.source.startswith('salt://') -%}
  12. {%- set file_source = user_files.source -%}
  13. {%- else -%}
  14. {%- set file_source = ('salt://' ~ user.user_files.source) -%}
  15. {%- endif -%}
  16. {%- set skip_user = False -%}
  17. {%- else -%}
  18. {%- if ('users/files/user/' ~ username) in userfile_dirs -%}
  19. {%- set file_source = ('salt://users/files/user/' ~ username) -%}
  20. {%- set skip_user = False -%}
  21. {%- else -%}
  22. {%- set skip_user = True -%}
  23. {%- endif -%}
  24. {%- endif -%}
  25. {%- if not skip_user %}
  26. users_userfiles_{{ username }}_recursive:
  27. file.recurse:
  28. - name: {{ user_home }}
  29. - source: {{ file_source }}
  30. - user: {{ username }}
  31. - group: {{ user_group }}
  32. - clean: False
  33. - include_empty: True
  34. - keep_symlinks: True
  35. - require:
  36. - user: users_{{ username }}_user
  37. - file: users_{{ username }}_user
  38. {% endif -%}
  39. {%- endif -%}
  40. {%- endfor -%}