2018-10-16 18:53:36 +00:00
|
|
|
---
|
|
|
|
- block:
|
2018-10-26 19:56:47 +00:00
|
|
|
- name: Setup global config file
|
|
|
|
template:
|
|
|
|
src: postgresql/data/postgresql.conf.j2
|
|
|
|
dest: "{{ __postgres_config_path }}/postgresql.conf"
|
|
|
|
mode: 0600
|
|
|
|
notify: __postgres_restart
|
2018-10-17 20:26:30 +00:00
|
|
|
|
2018-10-26 19:56:47 +00:00
|
|
|
- name: Create local users for pam auth
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
2019-08-27 20:55:28 +00:00
|
|
|
loop: "{{ postgres_users }}"
|
2019-10-27 15:56:16 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
2018-10-26 19:56:47 +00:00
|
|
|
when: item.pam_user | default(False)
|
2018-10-22 20:10:06 +00:00
|
|
|
|
2018-10-26 19:56:47 +00:00
|
|
|
- name: Setup client authentication
|
2019-10-23 07:44:56 +00:00
|
|
|
postgresql_pg_hba:
|
2018-10-26 19:56:47 +00:00
|
|
|
dest: "{{ __postgres_config_path }}/pg_hba.conf"
|
2019-10-23 07:44:56 +00:00
|
|
|
contype: "{{ item.contype | default('local') }}"
|
2019-10-23 07:48:39 +00:00
|
|
|
users: "{{ item.users | default(['all']) | join(',') }}"
|
2019-10-23 07:54:14 +00:00
|
|
|
address: "{{ item.address | default('all') }}"
|
2019-10-23 07:48:39 +00:00
|
|
|
databases: "{{ item.databases | default(['all']) | join(',') }}"
|
2022-04-04 19:51:15 +00:00
|
|
|
method: "{{ item.auth_method | default(postgres_password_encryption) }}"
|
2019-10-23 07:44:56 +00:00
|
|
|
state: "{{ item.state | default('present') }}"
|
2019-10-23 08:00:52 +00:00
|
|
|
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
|
2019-10-23 07:44:56 +00:00
|
|
|
loop_control:
|
2019-10-23 07:54:14 +00:00
|
|
|
label: "{{ item.address | default('samehost') }}:{{ item.databases | default(['all']) | join(',') }}:{{ item.users | default(['all']) | join(',') }}"
|
2018-10-26 19:56:47 +00:00
|
|
|
notify: __postgres_restart
|
2018-10-16 18:53:36 +00:00
|
|
|
become: True
|
|
|
|
become_user: root
|