Saltstack Official Users Formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

user_files.sls 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 current = salt.user.info(username) -%}
  7. {%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%}
  8. {%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%}
  9. {%- set user_home = salt['pillar.get'](('users:' ~ username ~ ':home'), current.get('home', '/home/' ~ username )) -%}
  10. {%- set user_files_template = salt['pillar.get'](('users:' ~ username ~ ':user_files:template'), None) -%}
  11. {%- set user_files_file_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:file_mode'), False) -%}
  12. {%- set user_files_sym_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:sym_mode'), False) -%}
  13. {%- if user_files.enabled -%}
  14. {%- if user_files.source is defined -%}
  15. {%- if user_files.source.startswith('salt://') -%}
  16. {%- set file_source = user_files.source -%}
  17. {%- else -%}
  18. {%- set file_source = ('salt://' ~ user.user_files.source) -%}
  19. {%- endif -%}
  20. {%- set skip_user = False -%}
  21. {%- else -%}
  22. {%- if ('users/files/user/' ~ username) in userfile_dirs -%}
  23. {%- set file_source = ('salt://users/files/user/' ~ username) -%}
  24. {%- set skip_user = False -%}
  25. {%- else -%}
  26. {%- set skip_user = True -%}
  27. {%- endif -%}
  28. {%- endif -%}
  29. {%- if not skip_user %}
  30. users_userfiles_{{ username }}_recursive:
  31. file.recurse:
  32. - name: {{ user_home }}
  33. - source: {{ file_source }}
  34. - user: {{ username }}
  35. - group: {{ user_group }}
  36. {% if user_files_template -%}
  37. - template: {{ user_files_template }}
  38. {% endif -%}
  39. - clean: False
  40. {% if user_files_file_mode -%}
  41. - file_mode: {{ user_files_file_mode }}
  42. {% endif -%}
  43. {% if user_files_sym_mode -%}
  44. - sym_mode: {{ user_files_sym_mode }}
  45. {% endif -%}
  46. - include_empty: True
  47. - keep_symlinks: True
  48. - require:
  49. - user: users_{{ username }}_user
  50. - file: users_{{ username }}_user
  51. {% endif -%}
  52. {%- endif -%}
  53. {%- endfor -%}