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.

55 líneas
2.0KB

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