-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Labels
Featurenew functionality including changes to functionality and code refactors, etc.new functionality including changes to functionality and code refactors, etc.
Milestone
Description
Currently, if I want to conditionally include an sls file, if the file exists, I need to do some ugly jinja magic:
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 service_group_sls = '{0}/{1}.sls'.format(root, grains['service_group']) -%}
# Check to see if the file exists, if so, include that pillar file.
{% if salt['file.file_exists'](service_group_sls) %}
'service_group:{{ grains["service_group"] }}':
- match: grain
- {{ grains['service_group'] }}
{% endif %}
{% endfor -%}
What I really want to do is:
base:
'service_group:{{ grains["service_group"] }}':
- match: grain
- ignore_missing: True
- {{ grains['service_group'] }}
I also want to see if a pillar or state sls file exists from the cli, or from inside of a state, for conditional include:
salt-call state.sls_exists mystatssls
salt-call pillar.sls_exists mypillarsls
This way I can call individual states, but only if they actually exist.
rwdalpe, fladi, OrangeDog, SN71, konstest and 1 more
Metadata
Metadata
Assignees
Labels
Featurenew functionality including changes to functionality and code refactors, etc.new functionality including changes to functionality and code refactors, etc.