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.

user_files.sls 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. {%- if user_files.enabled -%}
  9. {%- if user_files.source is defined -%}
  10. {%- if user_files.source.startswith('salt://') -%}
  11. {%- set file_source = user_files.source -%}
  12. {%- else -%}
  13. {%- set file_source = ('salt://' ~ user.user_files.source) -%}
  14. {%- endif -%}
  15. {%- set skip_user = False -%}
  16. {%- else -%}
  17. {%- if ('users/files/user/' ~ username) in userfile_dirs -%}
  18. {%- set file_source = ('salt://users/files/user/' ~ username) -%}
  19. {%- set skip_user = False -%}
  20. {%- else -%}
  21. {%- set skip_user = True -%}
  22. {%- endif -%}
  23. {%- endif -%}
  24. {%- if not skip_user %}
  25. users_userfiles_{{ username }}_recursive:
  26. file.recurse:
  27. - name: {{ user.home }}
  28. - source: {{ file_source }}
  29. - user: {{ username }}
  30. - group: {{ user_group }}
  31. - clean: False
  32. - include_empty: True
  33. - keep_symlinks: True
  34. - require:
  35. - user: users_{{ username }}_user
  36. - file: users_{{ username }}_user
  37. {% endif -%}
  38. {%- endif -%}
  39. {%- endfor -%}