Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 8586df6

Browse files
committed
Update to latest version of PostgreSQL role.
1 parent 99951b2 commit 8586df6

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

provisioning/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
- src: geerlingguy.postfix
6767
version: 1.1.0
6868
- src: geerlingguy.postgresql
69-
version: 1.0.3
69+
version: 1.1.0
7070
- src: geerlingguy.redis
7171
version: 1.4.1
7272
- src: geerlingguy.repo-remi

provisioning/roles/geerlingguy.postgresql/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ The directories (usually one, but can be multiple) where PostgreSQL's socket wil
3737

3838
Global configuration options that will be set in `postgresql.conf`. Note that for RHEL/CentOS 6 (or very old versions of PostgreSQL), you need to at least override this variable and set the `option` to `unix_socket_directory`.
3939

40+
postgresql_hba_entries:
41+
- type: host # required; local, host, hostssl or hostnossl
42+
database: exampledb # required
43+
user: jdoe # required
44+
address: 192.0.2.0/24 # either this or ip_address / ip_mask are required unless type is 'local'
45+
ip_address: # alternative to 'address'
46+
ip_mask: # alternative to 'address'
47+
auth_method: # required
48+
auth_options: # optional
49+
50+
Configure [host based authentication](https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html) entries to be set in the `pg_hba.conf`.
51+
4052
postgresql_locales:
4153
- 'en_US.UTF-8'
4254

provisioning/roles/geerlingguy.postgresql/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ postgresql_global_config_options:
1313
- option: unix_socket_directories
1414
value: '{{ postgresql_unix_socket_directories | join(",") }}'
1515

16+
# Host based authentication (hba) entries to be added to the pg_hba.conf.
17+
postgresql_hba_entries:
18+
- type: local
19+
database: all
20+
user: all
21+
auth_method: trust
22+
1623
# Debian only. Used to generate the locales used by PostgreSQL databases.
1724
postgresql_locales:
1825
- 'en_US.UTF-8'

provisioning/roles/geerlingguy.postgresql/tasks/configure.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
with_items: "{{ postgresql_global_config_options }}"
99
notify: restart postgresql
1010

11+
- name: Configure host based authentication.
12+
template:
13+
src: "templates/pg_hba.conf.j2"
14+
dest: "{{ postgresql_config_path }}/pg_hba.conf"
15+
owner: "{{ postgresql_user }}"
16+
group: "{{ postgresql_group }}"
17+
mode: 0600
18+
notify: restart postgresql
19+
1120
- name: Ensure PostgreSQL unix socket dirs exist.
1221
file:
1322
path: "{{ item }}"

provisioning/roles/geerlingguy.postgresql/tasks/databases.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
login_user: "{{ item.login_user | default(postgresql_user) }}"
1212
login_unix_socket: "{{ item.login_unix_socket | default(postgresql_unix_socket_directories[0]) }}"
1313
port: "{{ item.port | default(omit) }}"
14+
owner: "{{ item.owner | default(postgresql_user) }}"
1415
state: "{{ item.state | default('present') }}"
1516
with_items: "{{ postgresql_databases }}"
1617
become: yes

provisioning/roles/geerlingguy.postgresql/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
enabled: yes
2323

2424
# Configure PostgreSQL.
25-
- include: databases.yml
2625
- include: users.yml
26+
- include: databases.yml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{ ansible_managed | comment }}
2+
# PostgreSQL Client Authentication Configuration File
3+
# ===================================================
4+
#
5+
# See: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
6+
7+
{% for client in postgresql_hba_entries %}
8+
{{ client.type }} {{ client.database }} {{ client.user }} {{ client.address|default('') }} {{ client.ip_address|default('') }} {{ client.ip_mask|default('') }} {{ client.auth_method }} {{ client.auth_options|default("") }}
9+
{% endfor %}

0 commit comments

Comments
 (0)