{%- from "roles.jinja" import roles with context %}
{% set states = salt['cp.list_states'](saltenv) %}
include:
  - roles.nginx.none
{%- if roles is not none -%}
  {%- if 'portal' in roles -%}
    {%- for state in states %}
      {%- if state.startswith("pillars.roles.nginx.") -%}
        {%- set role = state.split('.')[3] %}
  - roles.nginx.{{ role }}
      {%- endif -%}
    {%- endfor -%}
  {%- else -%}
    {%- for role in roles %}
      {%- if 'pillars.roles.nginx.'+role in states %}
  - roles.nginx.{{ role }}
      {%- endif -%}
    {%- endfor -%}
  {%- endif -%}
{%- endif -%}