Browse Source

Merge pull request #143 from hatifnatt/dev

Add ability to specify mode for files and symlinks in user_files
tags/v0.45.0
Niels Abspoel 7 years ago
parent
commit
e03458bb31
2 changed files with 13 additions and 0 deletions
  1. +5
    -0
      pillar.example
  2. +8
    -0
      users/user_files.sls

+ 5
- 0
pillar.example View File

# should be a salt fileserver path either with or without 'salt://' # should be a salt fileserver path either with or without 'salt://'
# if not present, it defaults to 'salt://users/files/user/<username> # if not present, it defaults to 'salt://users/files/user/<username>
source: users/files/default source: users/files/default
# You can specify octal mode for files and symlinks that will be copied. Since version 2016.11.0
# it's possible to use 'keep' for file_mode, to preserve file original mode, thus you can save
# execution bit for example.
file_mode: keep
sym_mode: 640


## Absent user ## Absent user
cuser: cuser:

+ 8
- 0
users/user_files.sls View File

{%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%} {%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%}
{%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%} {%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%}
{%- set user_home = salt['pillar.get'](('users:' ~ username ~ ':home'), current.get('home', '/home/' ~ username )) -%} {%- set user_home = salt['pillar.get'](('users:' ~ username ~ ':home'), current.get('home', '/home/' ~ username )) -%}
{%- set user_files_file_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:file_mode'), False) -%}
{%- set user_files_sym_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:sym_mode'), False) -%}
{%- if user_files.enabled -%} {%- if user_files.enabled -%}


{%- if user_files.source is defined -%} {%- if user_files.source is defined -%}
- user: {{ username }} - user: {{ username }}
- group: {{ user_group }} - group: {{ user_group }}
- clean: False - clean: False
{% if user_files_file_mode -%}
- file_mode: {{ user_files_file_mode }}
{% endif -%}
{% if user_files_sym_mode -%}
- sym_mode: {{ user_files_sym_mode }}
{% endif -%}
- include_empty: True - include_empty: True
- keep_symlinks: True - keep_symlinks: True
- require: - require:

Loading…
Cancel
Save