2018-10-16 18:53:36 +00:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- 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-17 20:19:04 +00:00
|
|
|
- name: Setup client authentication
|
|
|
|
template:
|
2018-10-17 20:26:30 +00:00
|
|
|
src: postgresql/data/pg_hba.conf.j2
|
2018-10-17 20:19:04 +00:00
|
|
|
dest: "{{ __postgres_config_path }}/pg_hba.conf"
|
|
|
|
mode: 0600
|
2018-10-17 20:26:30 +00:00
|
|
|
notify: __postgres_restart
|
2018-10-16 18:53:36 +00:00
|
|
|
become: True
|
|
|
|
become_user: root
|
2018-10-18 20:59:39 +00:00
|
|
|
|
|
|
|
- name: Ensure PostgreSQL users are present
|
2018-10-18 21:09:06 +00:00
|
|
|
postgresql_user:
|
2018-10-18 20:59:39 +00:00
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.password | default(omit) }}"
|
|
|
|
encrypted: "{{ item.encrypted | default('yes') }}"
|
|
|
|
priv: "{{ item.priv | default(omit) }}"
|
|
|
|
role_attr_flags: "{{ item.role_attr_flags | default(omit) }}"
|
|
|
|
db: "{{ item.db | default(omit) }}"
|
|
|
|
login_host: "{{ item.login_host | default('localhost') }}"
|
|
|
|
login_password: "{{ item.login_password | default(omit) }}"
|
2018-10-18 21:07:39 +00:00
|
|
|
login_user: "{{ item.login_user | default(postgres_user) }}"
|
|
|
|
login_unix_socket: "{{ item.login_unix_socket | default(postgres_socket_directories[0]) }}"
|
2018-10-18 20:59:39 +00:00
|
|
|
port: "{{ item.port | default(omit) }}"
|
|
|
|
state: "{{ item.state | default('present') }}"
|
2018-10-18 21:07:39 +00:00
|
|
|
with_items: "{{ postgres_users }}"
|
2018-10-18 20:59:39 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
become: true
|
2018-10-18 21:07:39 +00:00
|
|
|
become_user: "{{ postgres_user }}"
|