{%- set service_grains = {'sphinx': {'doc': {}}} %} {%- for service_name, service in pillar.items() %} {%- if service.get('_support', {}).get('sphinx', {}).get('enabled', False) %} {%- set grains_fragment_file = service_name+'/meta/sphinx.yml' %} {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %} {%- set grains_yaml = load_grains_file()|load_yaml %} {%- set _dummy = service_grains.sphinx.doc.update({ service_name: grains_yaml.doc }) %} {%- endif %} {%- endfor %} {{ service_grains|yaml(False) }}