{{ ansible_managed | comment }}
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# See: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html

# TYPE  DATABASE        USER            ADDRESS                 METHOD
## localhost connections through Unix port (user name), IPv4, IPv6 (MD5 pw).
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

## remote connections IPv4
{% if postgres_allowed_hosts and postgres_allowed_hosts is iterable -%}
{%- for host in postgres_allowed_hosts %}
{{ host.type | default('host') }}         {{ host.database | default('all') }}        {{ host.user | default('all') }}             {{ host.address | default('0.0.0.0/0') }}            {{ item.auth | default('trust') }}
{% endfor %}
{% endif %}
