xoxys.postgres/tasks/config.yml
2018-10-18 23:09:06 +02:00

48 lines
1.6 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: Setup client authentication
template:
src: postgresql/data/pg_hba.conf.j2
dest: "{{ __postgres_config_path }}/pg_hba.conf"
mode: 0600
notify: __postgres_restart
become: True
become_user: root
- name: Ensure linux user '{{ postgres_user }}' is present
user:
name: "{{ item.name }}"
password: "{{ item.password }}"
with_items: "{{ postgres_users }}"
when: item.name == postgres_user
- name: Force all notified handlers to activate pg_hba.conf
meta: flush_handlers
- name: Ensure PostgreSQL users are present
postgresql_user:
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) }}"
login_user: "{{ item.login_user | default(postgres_user) }}"
login_unix_socket: "{{ item.login_unix_socket | default(postgres_socket_directories[0]) }}"
port: "{{ item.port | default(omit) }}"
state: "{{ item.state | default('present') }}"
with_items: "{{ postgres_users }}"
loop_control:
label: "{{ item.name }}"
become: true
become_user: "{{ postgres_user }}"