xoxys.postgres/tasks/config.yml

41 lines
1.6 KiB
YAML
Raw Normal View History

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-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-26 12:11:06 +00:00
no_log: "{{ postgres_no_log }}"
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
postgresql_pg_hba:
2018-10-26 19:56:47 +00:00
dest: "{{ __postgres_config_path }}/pg_hba.conf"
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(',') }}"
method: "{{ item.auth_method | default('md5') }}"
state: "{{ item.state | default('present') }}"
2019-10-23 08:00:52 +00:00
loop: "{{ postgres_hba_entries + postgres_hba_entries_extra }}"
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
- name: Open ports in iptables
iptables_raw:
name: allow_postgres_port
state: present
rules: '-A INPUT -m state --state NEW -p tcp --dport {{ postgres_connection_port }} -j ACCEPT'
2019-06-10 13:05:20 +00:00
when: postgres_iptables_enabled | bool
2018-10-16 18:53:36 +00:00
become: True
become_user: root