fix: pg_hba when multiple users or multiple databases

This commit is contained in:
Adrien Waksberg 2021-10-22 10:26:56 +02:00
parent 44ac805f2c
commit 7b4e1b63f4
4 changed files with 6 additions and 4 deletions

View file

@ -13,6 +13,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Fixed
- fix replication database in pg_hba
- fix pg_hba when multiple users or multiple databases
## v1.0.0 - 2021-09-10

View file

@ -2,7 +2,7 @@
- name: Converge
hosts: all
roles:
- ansible-role-postgresql
- postgresql
vars:
postgresql_use_official_repository: true
postgresql_primary: true
@ -12,11 +12,13 @@
- type: hostssl
databases:
- myappli
- myappli2
users: all
subnet: samenet
method: md5
postgresql_databases:
- name: myappli
- name: myappli2
postgresql_users:
- name: myuser
database: myappli

View file

@ -21,8 +21,7 @@ def test_hba_file(host):
assert path.user == 'root'
assert path.group == 'root'
assert path.mode == 0o644
assert path.contains('hostssl "myappli" all samenet md5')
assert path.contains('hostssl "myappli","myappli2" all samenet md5')
def test_service(host):
service = host.service('postgresql@13-main')

View file

@ -2,5 +2,5 @@
local all postgres peer
{% for conn in postgresql_hba %}
{{ conn.type }} {% if conn.databases in ['all', 'replication'] %}{{ conn.databases }}{% else %}"{{ conn.databases|join('",') }}"{% endif %} {% if conn.users == 'all' %}all{% else %}"{{ conn.users|join('",') }}"{% endif %}{% if conn.type != 'local' %} {{ conn.subnet }}{%endif %} {{ conn.method }}
{{ conn.type }} {% if conn.databases in ['all', 'replication'] %}{{ conn.databases }}{% else %}"{{ conn.databases|join('","') }}"{% endif %} {% if conn.users == 'all' %}all{% else %}"{{ conn.users|join('","') }}"{% endif %}{% if conn.type != 'local' %} {{ conn.subnet }}{%endif %} {{ conn.method }}
{% endfor %}