Skip to content

Instantly share code, notes, and snippets.

@ryan-lane
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryan-lane/e3f3bd08b75942107e52 to your computer and use it in GitHub Desktop.
Save ryan-lane/e3f3bd08b75942107e52 to your computer and use it in GitHub Desktop.
Load pillar files in the top file based on the grain
base:
# For each directory that can have pillar files
{% for root in opts['pillar_roots']['base'] -%}
# Set a variable to the path to check
{% set mygrain_sls = '{0}/{1}.sls'.format(root, grains['mygrain']) -%}
# Check to see if the file exists, if so, include that pillar file.
{% if salt['file.file_exists'](mygrain_sls) %}
'service_group:{{ grains["mygrain"] }}':
- match: grain
- {{ grains['mygrain'] }}
{% endif %}
{% endfor -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment