Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx example
# /srv/salt/nginx/init.sls
nginx:
pkgrepo:
# Set up the package repository with PPA
- managed
- ppa: nginx/stable
# This is telling SaltStack that when running pkg module, this is its dependency
# This is a reverse way of setting requirements
- require_in:
- pkg: nginx
pkg:
# Install the package
- installed
service:
- running
- require:
- pkg: nginx
- watch:
# When something here changes, restart the service
- pkg: nginx
- file: /etc/nginx/sites-enabled/
- file: /etc/nginx/nginx.conf
/etc/nginx/nginx.conf:
file:
- managed
- source: salt://nginx/nginx.conf.jinja
- user: root
- group: root
- mode: 644
- template: jinja
- require:
- pkg: nginx
# /srv/salt/nginx/nginx.conf.jinja
user www-data;
worker_processes {{ pillars['nginx']['num_of_workers_per_cpu'] * grains['num_cpus'] }};
pid /run/nginx.pid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment