Add 'template' support to 'user_files' (#159)

* Add support for 'template' in 'user_files'

* Fix-up wrong nesting level for template value

* Small quality improvement for push upstream.

* Consistency improvement for variable name
This commit is contained in:
Jerry van Leeuwen 2017-09-21 20:30:29 -07:00 committed by Toby Brain
parent e03458bb31
commit 4da9b00e75
2 changed files with 5 additions and 0 deletions

View File

@ -125,6 +125,7 @@ users:
# 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
template: jinja
# You can specify octal mode for files and symlinks that will be copied. Since version 2016.11.0 # 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 # it's possible to use 'keep' for file_mode, to preserve file original mode, thus you can save
# execution bit for example. # execution bit for example.

View File

@ -9,6 +9,7 @@ include:
{%- 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_template = salt['pillar.get'](('users:' ~ username ~ ':user_files:template'), None) -%}
{%- set user_files_file_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:file_mode'), False) -%} {%- 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) -%} {%- set user_files_sym_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:sym_mode'), False) -%}
{%- if user_files.enabled -%} {%- if user_files.enabled -%}
@ -36,6 +37,9 @@ users_userfiles_{{ username }}_recursive:
- source: {{ file_source }} - source: {{ file_source }}
- user: {{ username }} - user: {{ username }}
- group: {{ user_group }} - group: {{ user_group }}
{%- if user_files_template is not None -%}
- template: {{ user_files_template }}
{%- endif -%}
- clean: False - clean: False
{% if user_files_file_mode -%} {% if user_files_file_mode -%}
- file_mode: {{ user_files_file_mode }} - file_mode: {{ user_files_file_mode }}