Skip to content

Instantly share code, notes, and snippets.

@mech422
Created September 20, 2013 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mech422/6633041 to your computer and use it in GitHub Desktop.
Save mech422/6633041 to your computer and use it in GitHub Desktop.
##
## salt '*' grains.setval key val
## salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}"
##
{% set id = grains.id %}
{% set os = grains.os %}
{% set node_type = pillar.node_type %}
{% set node_role = pillar.node_role %}
{% set key = id + '-sls-base-nginx-_action' %}
{% set _action = salt['grains.get'](key,'foo') %}
## Move this to a map file...
{% set default_server = 'nginx' %}
{% from "nginx/pkgconfig.jinja" import pkg_conf with context %}
{% if _action == 'install' %}
install_nginx:
pkg:
- installed
- name: {{ pkg_conf.server }}
service:
- running
- name: {{ pkg_conf.service }}
- enable: True
{{ key }}:
grains:
- present
- value: 'install_complete'
- watch:
- service: install_nginx
{% endif %}
{% if _action == 'remove' %}
remove_nginx:
pkg:
- removed
- name: {{ pkg_conf.service }}
{% endif %}
## salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}"
{% set id = grains.id %}
{% set key = id + '-sls-base-nginx-_action' %}
{% set tmp = salt['grains.setval']( key, 'install' ) %}
## This will include nginx/init.sls by default
include:
- nginx
## salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}"
{% set id = grains.id %}
{% set key = id + '-sls-base-nginx-_action' %}
{% set tmp = salt['grains.setval']( key, 'remove' ) %}
## This will include nginx/init.sls by default
include:
- nginx
@mech422
Copy link
Author

mech422 commented Sep 20, 2013

salt '*' grains.setval key val

salt '*' grains.setval key "{'sub-key': 'val', 'sub-key2': 'val2'}"

{% set pkg_conf = salt['grains.filter_by']({
'default': {
'server': 'nginx'
},
'Debian': {
'server': 'nginx',
'service': 'nginx',
'vhostdir': '/etc/nginx/sites-available',
'confdir': '/etc/nginx/conf.d',
'logdir': '/var/log/nginx',
},
'Ubuntu': {
'server': 'nginx',
'service': 'nginx',
},

}) %}

}, merge=salt'pillar.get') % }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment