---
application_id: "web-svc-coturn"
entity_name: "{{ application_id | entity_name }}"
domain: "{{ lookup('domain',application_id) }}"
COTURN_CONTAINER: "{{ entity_name }}"
COTURN_REALM: "{{ domain }}"
COTURN_NETWORK_MODE: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.network_mode') }}"
COTURN_LOOPBACK_IP: "127.0.0.1"
COTURN_RELAY_IP: "{{ networks.internet.ip4 }}"
# nocheck: host-local-fact read only for host networking in compose mode, where the host rendering this file is the host coturn binds on; Ansible omits both keys on a host without the ip binary, which leaves coturn unpinned
COTURN_HOST_ADDRESSES: "{{ (ansible_facts['all_ipv4_addresses'] | default([])) + (ansible_facts['all_ipv6_addresses'] | default([])) }}"
COTURN_IP6_UNSET: "{{ networks.internet.ip6 in ['', defaults_networks.internet.ip6] }}"
COTURN_ADDRESSES_PINNED: "{{ COTURN_NETWORK_MODE == 'host' and (IS_COMPOSE_MODE | bool) and COTURN_RELAY_IP in COTURN_HOST_ADDRESSES and (COTURN_IP6_UNSET or networks.internet.ip6
in COTURN_HOST_ADDRESSES) }}"
COTURN_LISTENING_IPS: "{{ [COTURN_RELAY_IP, COTURN_LOOPBACK_IP] + ([] if COTURN_IP6_UNSET else [networks.internet.ip6]) }}"
COTURN_STUN_TURN_PORT: "{{ lookup('config', application_id, 'services.coturn.ports.public.stun_turn') }}"
COTURN_STUN_TURN_PORT_TLS: "{{ lookup('config', application_id, 'services.coturn.ports.public.stun_turn_tls') }}"
COTURN_RELAY_PORT_START: "{{ lookup('config', application_id, 'services.coturn.ports.public.relay.start') }}"
COTURN_RELAY_PORT_END: "{{ lookup('config', application_id, 'services.coturn.ports.public.relay.end') }}"
COTURN_TOTAL_QUOTA: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.total_quota') }}"
COTURN_USER_NAME: "{{ lookup('users', 'coturnconsumer').username }}"
COTURN_USER_PASSWORD: "{{ lookup('users', 'coturnconsumer').password }}"
COTURN_STATIC_AUTH_SECRET: "{{ lookup('config', application_id, 'secrets.credentials.auth_secret') }}"
COTURN_USER_AUTH_ENABLED: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.user_auth_enabled') }}"
COTURN_TLS_ENABLED: "{{ lookup('tls', application_id, 'enabled') | bool }}"
COTURN_TLS_CERT_PATH: "{{ lookup('cert', application_id, 'files.cert') }}"
COTURN_TLS_KEY_PATH: "{{ lookup('cert', application_id, 'files.key') }}"