Skip to content

Commit a9fcc1a

Browse files
committed
Don't clobber the default scram-sha-256 auth method used in the default
pg_hba.conf on PG 14+
1 parent cffcfd9 commit a9fcc1a

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ postgresql_backup_command: >-
3535
--keep {{ postgresql_backup_keep | quote }}
3636
{{ '--pg-bin-dir ' ~ __postgresql_pgdg_bin_dir if ansible_os_family == 'RedHat' else '' }}
3737
--backup --clean-archive {{ postgresql_backup_dir | quote }}
38+
39+
postgresql_default_auth_method: "{{ (postgresql_version is version('13', '>')) | ternary('scram-sha-256', 'md5') }}"

templates/pg_hba.conf.debian.j2

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## This file is maintained by Ansible - CHANGES WILL BE OVERWRITTEN
33
##
44

5-
{% if postgresql_pg_hba_local_postgres_user is not defined or postgresql_pg_hba_local_postgres_user %}
5+
{% if postgresql_pg_hba_local_postgres_user | default(true) | bool %}
66
# DO NOT DISABLE!
77
# If you change this first entry you will need to make sure that the
88
# database superuser can access the database using some other method.
@@ -13,22 +13,24 @@
1313
local all postgres peer
1414
{% endif %}
1515

16-
{% if postgresql_pg_hba_local_socket is not defined or postgresql_pg_hba_local_socket %}
16+
# TYPE DATABASE USER ADDRESS METHOD
17+
18+
{% if postgresql_pg_hba_local_socket | default(true) %}
1719
# "local" is for Unix domain socket connections only
1820
local all all peer
1921
{% endif %}
20-
{% if postgresql_pg_hba_local_ipv4 is not defined or postgresql_pg_hba_local_ipv4 %}
22+
{% if postgresql_pg_hba_local_ipv4 | default(true) %}
2123
# IPv4 local connections:
22-
host all all 127.0.0.1/32 md5
24+
host all all 127.0.0.1/32 {{ postgresql_default_auth_method }}
2325
{% endif %}
24-
{% if postgresql_pg_hba_local_ipv6 is not defined or postgresql_pg_hba_local_ipv6 %}
26+
{% if postgresql_pg_hba_local_ipv6 | default(true) %}
2527
# IPv6 local connections:
26-
host all all ::1/128 md5
28+
host all all ::1/128 {{ postgresql_default_auth_method }}
2729
{% endif %}
2830

2931
# Entries configured in postgresql_pg_hba_conf follow
3032
{% if postgresql_pg_hba_conf is defined %}
31-
{% for line in postgresql_pg_hba_conf %}
33+
{% for line in postgresql_pg_hba_conf %}
3234
{{ line }}
3335
{% endfor %}
3436
{% endif %}

templates/pg_hba.conf.redhat.j2

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
## This file is maintained by Ansible - CHANGES WILL BE OVERWRITTEN
33
##
44

5-
{% if postgresql_pg_hba_local_socket is not defined or postgresql_pg_hba_local_socket %}
5+
# TYPE DATABASE USER ADDRESS METHOD
6+
7+
{% if postgresql_pg_hba_local_socket | default(true) %}
68
# "local" is for Unix domain socket connections only
79
local all all peer
810
{% endif %}
9-
{% if postgresql_pg_hba_local_ipv4 is not defined or postgresql_pg_hba_local_ipv4 %}
11+
{% if postgresql_pg_hba_local_ipv4 | default(true) %}
1012
# IPv4 local connections:
11-
host all all 127.0.0.1/32 ident
13+
host all all 127.0.0.1/32 {{ postgresql_default_auth_method }}
1214
{% endif %}
13-
{% if postgresql_pg_hba_local_ipv6 is not defined or postgresql_pg_hba_local_ipv6 %}
15+
{% if postgresql_pg_hba_local_ipv6 | default(true) %}
1416
# IPv6 local connections:
15-
host all all ::1/128 ident
17+
host all all ::1/128 {{ postgresql_default_auth_method }}
1618
{% endif %}
1719

1820
# Entries configured in postgresql_pg_hba_conf follow

0 commit comments

Comments
 (0)