forked from ISTI-ansible-roles/ansible-roles
37 lines
1.7 KiB
YAML
37 lines
1.7 KiB
YAML
---
|
|
- name: Install the packages needed by postgres when running behind a pgpool server
|
|
apt: pkg={{ item }} state={{ psql_pkg_state }}
|
|
with_items: '{{ postgresql_pgpool_pkgs }}'
|
|
when: psql_pgpool_install
|
|
notify: Restart postgresql
|
|
tags: [ 'postgresql', 'postgres', 'pgpool' ]
|
|
|
|
- name: Add the user that will manage the recovery, if not postgres
|
|
become: True
|
|
become_user: postgres
|
|
postgresql_user: user={{ pgpool_recovery_user }} password={{ pgpool_recovery_user_pwd }} role_attr_flags=REPLICATION port={{ psql_db_port }}
|
|
when:
|
|
- ('{{ pgpool_recovery_user }}' != 'postgres')
|
|
- pgpool_recovery_user_pwd is defined
|
|
tags: [ 'postgresql', 'postgres', 'pgpool' ]
|
|
|
|
- name: Give access to the pgpool recovery user, if it is not postgres
|
|
lineinfile: name=/etc/postgresql/{{ psql_version }}/main/pg_hba.conf regexp="^host {{ item.0.name }} {{ pgpool_recovery_user }} {{ item.1 }}.*$" line="host {{ item.0.name }} {{ pgpool_recovery_user }} {{ item.1 }} md5"
|
|
with_subelements:
|
|
- '{{ psql_db_data | default([]) }}'
|
|
- allowed_hosts
|
|
when:
|
|
- psql_db_data is defined
|
|
- item.1 is defined
|
|
- pgpool_recovery_user_pwd is defined
|
|
notify: Reload postgresql
|
|
tags: [ 'postgresql', 'postgres', 'pgpool' ]
|
|
|
|
- name: Install the pgpool recovery and remote restart scripts. They assume that the postgresql hosts can talk to each other
|
|
template: src={{ item.1 }}.j2 dest={{ item.0.backend_data_directory }}/{{ item.1 }} owner=postgres group=postgres mode=0500
|
|
with_nested:
|
|
- '{{ pgpool_backends | default([]) }}'
|
|
- [ '{{ pgpool_recovery_stage1_script }}', '{{ pgpool_recovery_stage2_script }}', '{{ pgpool_remote_start_script }}' ]
|
|
tags: [ 'postgresql', 'postgres', 'pgpool' ]
|
|
|