xoxys.postgres/tasks/config.yml

35 lines
1.4 KiB
YAML
Raw Normal View History

2018-10-16 20:53:36 +02:00
---
- block:
2018-10-26 21:56:47 +02: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-26 21:56:47 +02: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 22:55:28 +02:00
loop: "{{ postgres_users }}"
2019-10-27 16:56:16 +01:00
loop_control:
label: "{{ item.name }}"
2018-10-26 21:56:47 +02:00
when: item.pam_user | default(False)
2018-10-22 22:10:06 +02:00
2018-10-26 21:56:47 +02:00
- name: Setup client authentication
postgresql_pg_hba:
2018-10-26 21:56:47 +02:00
dest: "{{ __postgres_config_path }}/pg_hba.conf"
contype: "{{ item.contype | default('local') }}"
2019-10-23 09:48:39 +02:00
users: "{{ item.users | default(['all']) | join(',') }}"
2019-10-23 09:54:14 +02:00
address: "{{ item.address | default('all') }}"
2019-10-23 09:48:39 +02:00
databases: "{{ item.databases | default(['all']) | join(',') }}"
method: "{{ item.auth_method | default('md5') }}"
state: "{{ item.state | default('present') }}"
2019-10-23 10:00:52 +02:00
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
loop_control:
2019-10-23 09:54:14 +02:00
label: "{{ item.address | default('samehost') }}:{{ item.databases | default(['all']) | join(',') }}:{{ item.users | default(['all']) | join(',') }}"
2018-10-26 21:56:47 +02:00
notify: __postgres_restart
2018-10-16 20:53:36 +02:00
become: True
become_user: root