{% set pki_tpl_group_directories = [ 'external', 'private' ] %}
{% set pki_tpl_host_directories = [ 'external', 'internal', 'private' ] %}
  - 'pki/lib'
  - 'pki/ca-certificates/by-host/{{ pki_fqdn }}'
  - 'pki/ca-certificates/by-group/all'
{% for group in pki_inventory_groups %}
  - 'pki/ca-certificates/by-group/{{ group }}'
{% endfor %}
{% for realm in pki_realms + pki_default_realms %}
{%   if realm.name is defined and ((realm.enabled is undefined or realm.enabled|bool) and (realm.when is undefined or realm.when|bool)) %}
{%     for directory in pki_tpl_group_directories %}
  - 'pki/realms/by-group/all/{{ realm.name }}/{{ directory }}'
{%     endfor %}
{%   endif %}
{% endfor %}
{% for group in pki_inventory_groups %}
{%   for realm in pki_group_realms + pki_default_realms %}
{%     if realm.name is defined and ((realm.enabled is undefined or realm.enabled|bool) and (realm.when is undefined or realm.when|bool)) %}
{%       for directory in pki_tpl_group_directories %}
  - 'pki/realms/by-group/{{ group }}/{{ realm.name }}/{{ directory }}'
{%       endfor %}
{%     endif %}
{%   endfor %}
{% endfor %}
{% for realm in (pki_host_realms + pki_group_realms + pki_realms + pki_default_realms + pki_dependent_realms) %}
{%   if realm.name is defined and ((realm.enabled is undefined or realm.enabled|bool) and (realm.when is undefined or realm.when|bool)) %}
{%     for directory in pki_tpl_host_directories %}
  - 'pki/realms/by-host/{{ pki_fqdn }}/{{ realm.name }}/{{ directory }}'
{%     endfor %}
{%   endif %}
{% endfor %}
