Skip to content

Instantly share code, notes, and snippets.

@anorgan
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anorgan/099b6ddceefd9d56cfe8 to your computer and use it in GitHub Desktop.
Save anorgan/099b6ddceefd9d56cfe8 to your computer and use it in GitHub Desktop.
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