Skip to content

Instantly share code, notes, and snippets.

@renoirb
Created November 1, 2013 22:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save renoirb/7272880 to your computer and use it in GitHub Desktop.
Save renoirb/7272880 to your computer and use it in GitHub Desktop.
Salt stack, context and Jinja template
#
# Some state file...
#
{% for site, args in pillar.get('sites', {}).items() %}
/etc/nginx/sites-available/{{ site }}:
file.managed:
- source: salt://nginx/files/site.conf.jinja
- template: jinja
- context:
site: {{ site }}
args: {{ args }}
- watch_in:
- service: nginx
- require:
- pkg: nginx
{% if 'enable' in args and args.enable == True %}
/etc/nginx/sites-enabled/{{ site }}:
file.symlink:
- target: /etc/nginx/sites-available/{{ site }}
- require:
- pkg: nginx
{% else %}
/etc/nginx/sites-enabled/{{ site }}:
file.absent:
- require:
- pkg: nginx
{% endif %}
{% endfor %}
#
# The called Jinja template file
#
# file: nginx/files/site.conf.jinja
#
{# Some NGINX config... #}
{% if 'magento' in args and args.magento == True -%}
# Something happens only if args has a member 'magento' and its value is
# THE QUESTION: Is True here is BOOLEAN, or string, How can we check?
{% endif %}
#
# The "sites" pillar
#
# file: pillar/sites/init.sls
#
sites:
piwik:
name: stats.webplatform.org
default: True
enable: True
php: True
wordpress: False
http_server: nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment