-
-
Save coolpalani/c5ef9280071988b1638014447269ab59 to your computer and use it in GitHub Desktop.
modified psql replication script from sam doran's role. Works with Tower 3.0.3 and RHEL 6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Configure PostgreSQL streaming replication | |
hosts: database_slave | |
pre_tasks: | |
- name: Remove recovery.conf | |
file: | |
path: /var/lib/pgsql/9.4/data/recovery.conf | |
state: absent | |
- name: Add slave to database group | |
add_host: | |
name: "{{ inventory_hostname }}" | |
groups: database | |
tags: | |
- always | |
roles: | |
- role: packages_el | |
packages_el_install_tower: false | |
packages_el_install_postgres: true | |
when: ansible_os_family == "RedHat" | |
- role: postgres | |
tags: postgresql_database | |
postgres_allowed_ipv4: "0.0.0.0/0" | |
postgres_allowed_ipv6: "::/0" | |
postgres_username: "{{ pg_username }}" | |
postgres_password: "{{ pg_password }}" | |
postgres_database: "{{ pg_database }}" | |
max_postgres_connections: 1024 | |
postgres_shared_memory_size: "{{ (ansible_memtotal_mb*0.3)|int }}" | |
postgres_work_mem: "{{ (ansible_memtotal_mb*0.03)|int }}" | |
postgres_maintenance_work_mem: "{{ (ansible_memtotal_mb*0.04)|int }}" | |
- name: Configure master server | |
hosts: database[0] | |
vars: | |
postgresrep_master_address: "{{ hostvars[groups[postgresrep_group_name_master][0]].ansible_all_ipv4_addresses[0] }}" | |
postgresrep_slave_address: "{{ hostvars[groups[postgresrep_group_name][0]].ansible_all_ipv4_addresses[0] }}" | |
roles: | |
- postgres-replication | |
- name: Configure slave server | |
hosts: database_slave | |
vars: | |
postgresrep_master_address: "{{ hostvars[groups[postgresrep_group_name_master][0]].ansible_all_ipv4_addresses[0] }}" | |
postgresrep_slave_address: "{{ hostvars[groups[postgresrep_group_name][0]].ansible_all_ipv4_addresses[0] }}" | |
roles: | |
- postgres-replication |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment