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 -%}