{% macro trunk_options(opts) -%} {% for opt in (opts | d({}) | dict2items) -%} {{ opt.key }} = {{ 'yes' if (opt.value is boolean and opt.value == true) else ('no' if (opt.value is boolean and opt.value == false) else opt.value ) }} {% endfor -%} {% endmacro -%} {% for user in asterisk_users | d({}) | dict2items -%} {% if user.value is mapping -%} {% if user.value['__comment__'] is string -%} ; {{ user.value['__comment__'] }} {% endif -%} [auth-{{ user.key }}](auth-common) username = {{ user.value['login'] | d(user.key) }} password = {{ user.value['password'] }} [{{ user.key }}](aor-common) [{{ user.key }}](endpoint-lan) auth = auth-{{ user.key }} aors = {{ user.key }} callerid = {{ user.value['callerid'] | d(user.key) }} <{{ user.key }}> {% endif -%} {% endfor %} {% for trunk in asterisk_trunks | d({}) | dict2items -%} {% if trunk.value is mapping -%} {% if trunk.value['__comment__'] is string -%} ; {{ trunk.value['__comment__'] }} {% endif -%} [transport-{{ trunk.key }}](transport-udp,transport-ext) {{ trunk_options(trunk.value['transport']) }} {# #} [registration-{{ trunk.key }}](registration-common) outbound_auth = auth-{{ trunk.key }} endpoint = endpoint-{{ trunk.key }} transport = transport-{{ trunk.key }} {{ trunk_options(trunk.value['registration']) }} {# #} [auth-{{ trunk.key }}](auth-common) {{ trunk_options(trunk.value['auth']) }} {# #} [aor-{{ trunk.key }}](aor-common) {{ trunk_options(trunk.value['aor']) }} {# #} [endpoint-{{ trunk.key }}](endpoint-trunk) transport = transport-{{ trunk.key }} context = inbound-{{ trunk.key }} outbound_auth = auth-{{ trunk.key }} aors = aor-{{ trunk.key }} {{ trunk_options(trunk.value['endpoint']) }} {# #} [identify-{{ trunk.key }}] type = identify endpoint = endpoint-{{ trunk.key }} {{ trunk_options(trunk.value['identify']) }} {%- if not loop.last %} {% endif -%} {% endif -%} {% endfor %} [reslist-all] type=resource_list event=presence list_item={{ asterisk_users | d({}) | dict2items | map(attribute='key') | list | join(',') }}