From a83f74c18e601bc268a1187c8198b7a8977210da Mon Sep 17 00:00:00 2001 From: Ryan Peck Date: Wed, 18 Mar 2015 13:36:19 -0400 Subject: [PATCH] Add optional templating to register_site Add optional templating for the register site aspect of a pillar. User can specify keys to be included as defaults, otherwise it is treated as a normal managed file. --- apache/register_site.sls | 7 +++++++ pillar.example | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/apache/register_site.sls b/apache/register_site.sls index 3f7d0d8..00a8135 100644 --- a/apache/register_site.sls +++ b/apache/register_site.sls @@ -38,6 +38,13 @@ - user: root - group: root - mode: 775 +{% if 'template' in pillar['apache']['register-site'][site] and 'defaults' in pillar['apache']['register-site'][site] %} + - template: jinja + - defaults: + {% for key, value in pillar['apache']['register-site'][site]['defaults'].iteritems() %} + {{ key }}: {{ value }} + {% endfor %} +{% endif %} - watch_in: - cmd: {{ a2modid }} - module: apache-reload diff --git a/pillar.example b/pillar.example index 87d104d..a04a9e3 100644 --- a/pillar.example +++ b/pillar.example @@ -81,6 +81,10 @@ apache: name: 'my name' path: 'salt://path/to/sites-available/conf/file' state: 'enabled' + # Optional - use managed file as Jinja Template + #template: true + #defaults: + # custom_var: "default value" modules: enabled: # List modules to enable