Theo Chatzimichos 37684d
{%- macro include_optional(sls_file) %}
Theo Chatzimichos 37684d
  {%- for root in opts['pillar_roots'][saltenv] -%}
Theo Chatzimichos 37684d
    {%- if salt['file.file_exists']('{0}/{1}/init.sls'.format(root, sls_file))  %}
Theo Chatzimichos 37684d
    - {{ sls_file }}
Theo Chatzimichos 37684d
    {% endif %}
Theo Chatzimichos 37684d
  {%- endfor %}
Theo Chatzimichos 37684d
{%- endmacro %}
Theo Chatzimichos 7ec47f
Theo Chatzimichos 7ec47f
{%- macro valid_virt_cluster() -%}
Theo Chatzimichos 7ec47f
  {%- import_yaml "valid_custom_grains.yaml" as valid_custom_grains -%}
Theo Chatzimichos 7ec47f
  {%- set valid_virt_cluster = [] -%}
Theo Chatzimichos 7ec47f
  {%- for country, data in valid_custom_grains['localized'].items() -%}
Theo Chatzimichos 7ec47f
    {%- if data['virt_cluster'] is iterable and data['virt_cluster'] is not string -%}
Theo Chatzimichos 7ec47f
      {%- for item in data['virt_cluster'] -%}
Theo Chatzimichos 7ec47f
        {%- do valid_virt_cluster.append(item) -%}
Theo Chatzimichos 7ec47f
      {%- endfor -%}
Theo Chatzimichos 7ec47f
    {%- else -%}
Theo Chatzimichos 7ec47f
      {%- do valid_virt_cluster.append(data['virt_cluster']) -%}
Theo Chatzimichos 7ec47f
    {%- endif -%}
Theo Chatzimichos 7ec47f
  {%- endfor -%}
Theo Chatzimichos 7ec47f
  {{ valid_virt_cluster }}
Theo Chatzimichos 7ec47f
{%- endmacro -%}