-
-
Save sysbot/4cf51bc9f0844e39c24dcc460960a1ff to your computer and use it in GitHub Desktop.
Salt stack, context and Jinja template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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