diff --git a/roles/postgresql/defaults/main.yml b/roles/postgresql/defaults/main.yml deleted file mode 100644 index 8eb5639..0000000 --- a/roles/postgresql/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -postgresql_hosts: [] -postgresql_databases: [] -postgresql_users: [] -... diff --git a/roles/postgresql/tasks/main.yml b/roles/postgresql/tasks/main.yml index 8a1800d..bde4367 100644 --- a/roles/postgresql/tasks/main.yml +++ b/roles/postgresql/tasks/main.yml @@ -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([]) }}" ... diff --git a/roles/postgresql/templates/postgresql/pg_hba.conf.j2 b/roles/postgresql/templates/postgresql/pg_hba.conf.j2 index bf8f545..bc14c01 100644 --- a/roles/postgresql/templates/postgresql/pg_hba.conf.j2 +++ b/roles/postgresql/templates/postgresql/pg_hba.conf.j2 @@ -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 %}