# {{ ansible_managed }}

# Database administrative login by Unix domain socket
local all postgres peer

# Unix domain socket for other users
local all all {% if pg_local_auth_method is defined %}{{ pg_local_auth_method }}{% elif pg_md5 %}md5{% else %}scram-sha-256{% endif %}

# localhost
host all all 127.0.0.1/32 {{ 'md5' if pg_md5 else 'scram-sha-256' }}

host all all ::1/128 {{ 'md5' if pg_md5 else 'scram-sha-256' }}

{% if pg_hba_config is defined %}

# other accesses
{% for item in pg_hba_config %}
{{ item.type }} {{ item.database }} {{ item.user }} {{ item.address }} {{ item.method }}
{% endfor %}
{% endif %}
