postgres: fix defaults

This commit is contained in:
Alexandre Iooss 2021-11-28 11:07:13 +01:00
parent 45802cf65d
commit fd0cb811a7
3 changed files with 4 additions and 9 deletions

View file

@ -1,5 +0,0 @@
---
postgresql_hosts: []
postgresql_databases: []
postgresql_users: []
...

View file

@ -55,7 +55,7 @@
lc_collate: en_US.UTF-8
lc_ctype: en_US.UTF-8
template: template0
loop: "{{ postgresql.databases }}"
loop: "{{ postgresql.databases | default([]) }}"
- name: Create users
become: true
@ -65,7 +65,7 @@
name: "{{ item.name }}"
password: "{{ item.password }}"
no_log: true
loop: "{{ postgresql.users }}"
loop: "{{ postgresql.users | default([]) }}"
- name: Grant privileges to users
become: true
@ -77,5 +77,5 @@
privs: "{{ item.privs | join(',') }}"
obj: "{{ item.database }}"
no_log: true
loop: "{{ postgresql.users }}"
loop: "{{ postgresql.users | default([]) }}"
...

View file

@ -2,6 +2,6 @@
# TYPE DATABASE USER ADDRESS METHOD
local all postgres peer map=map_local
{% for host in postgresql.hosts %}
{% for host in postgresql.hosts | default([]) %}
host "{{ host.database }}" "{{ host.user }}" {{ host.net }} {{ host.method }}
{% endfor %}