commit c611a535585d9b80fa91e490b6289f635ed3cae7 Author: nd Date: Thu Sep 13 18:57:12 2018 +0200 Initial commit diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..3cb7c70 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +postgresql: + allowed_hosts: [] diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..852591c --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +- name: restart postgres + service: name=postgresql state=restarted diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..358e156 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,13 @@ +- name: install postgres + apt: + pkg: postgresql + +- name: generate pg_hba + template: + src: pg_hba.conf.j2 + dest: /etc/postgresql/9.6/main/pg_hba.conf + owner: postgres + group: postgres + mode: 0640 + notify: + - restart postgres diff --git a/templates/pg_hba.conf.j2 b/templates/pg_hba.conf.j2 new file mode 100644 index 0000000..777d57d --- /dev/null +++ b/templates/pg_hba.conf.j2 @@ -0,0 +1,8 @@ +{% for item in postgresql.allowed_hosts %} +{{ item.type | default('host') }} {{ item.database | default('all') }} {{ item.user | default('all') }} {{ item.auth | default('md5') }} +{% endfor %} + +local all postgres peer +local all all peer +host all all 127.0.0.1/32 md5 +host all all ::1/128 md5