xoxys.postgres/tasks/config.yml
Robert Kaussow 7a3752d57b
Some checks failed
continuous-integration/drone/pr Build is failing
switch to postgres 14 as default
2022-04-03 14:53:03 +02:00

35 lines
1.4 KiB
YAML

---
- block:
- name: Setup global config file
template:
src: postgresql/data/postgresql.conf.j2
dest: "{{ __postgres_config_path }}/postgresql.conf"
mode: 0600
notify: __postgres_restart
- 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') }}"
loop: "{{ postgres_users }}"
loop_control:
label: "{{ item.name }}"
when: item.pam_user | default(False)
- name: Setup client authentication
postgresql_pg_hba:
dest: "{{ __postgres_config_path }}/pg_hba.conf"
contype: "{{ item.contype | default('local') }}"
users: "{{ item.users | default(['all']) | join(',') }}"
address: "{{ item.address | default('all') }}"
databases: "{{ item.databases | default(['all']) | join(',') }}"
method: "{{ item.auth_method | default(postgres_password_encryption) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
loop_control:
label: "{{ item.address | default('samehost') }}:{{ item.databases | default(['all']) | join(',') }}:{{ item.users | default(['all']) | join(',') }}"
notify: __postgres_restart
become: True
become_user: root