postgresql: variables in dict

This commit is contained in:
Alexandre Iooss 2021-11-28 10:45:21 +01:00
parent f0b8075ca6
commit 4bd431f9c3
5 changed files with 121 additions and 123 deletions

View file

@ -1,2 +0,0 @@
---
postgresql_databases: true

View file

@ -5,7 +5,7 @@
vars:
postgresql:
version: 13
postgresql_hosts:
hosts:
- database: nextcloud
user: nextcloud
net: 10.128.0.58/32
@ -30,14 +30,14 @@
user: grafana
net: 10.128.0.98/32
method: md5
postgresql_databases:
databases:
- nextcloud
- gitea
- wikijs
- drone
- netbox
- grafana
postgresql_users:
users:
- name: nextcloud
database: nextcloud
password: "{{ vault_postgresql_nextcloud_passwd }}"
@ -79,7 +79,7 @@
vars:
postgresql:
version: 13
postgresql_hosts:
hosts:
- database: etherpad
user: etherpad
net: 10.128.0.150/32
@ -100,13 +100,13 @@
user: cas
net: 10.128.0.150/32
method: md5
postgresql_databases:
databases:
- synapse
- codimd
- etherpad
- kanboard
- cas
postgresql_users:
users:
- name: synapse
database: synapse
password: "{{ vault_postgresql_synapse_passwd }}"

View file

@ -42,7 +42,7 @@ consistency:
- repository
- archives
{% if postgresql_databases is defined %}
{% if borg_postgresql_databases is defined %}
hooks:
postgresql_databases:
- name: all

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 }}"
- name: Create users
become: true
@ -65,7 +65,7 @@
name: "{{ item.name }}"
password: "{{ item.password }}"
no_log: true
loop: "{{ postgresql_users }}"
loop: "{{ postgresql.users }}"
- 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 }}"
...

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 %}
host "{{ host.database }}" "{{ host.user }}" {{ host.net }} {{ host.method }}
{% endfor %}