Skip to content

Commit

Permalink
[v0.8] Pgpool not showing Replication State (#2044)
Browse files Browse the repository at this point in the history
* Correct backend_application_name in pgpool.conf

* Group tasks and change order

* Remove unneeded tasks

* Group tasks using blocks

* Improve code

* Create symlink /etc/repmgr.conf

* Shorten repmgr commands due to symlink to config file

* Ensure postgresql instance is stopped

* Update changelog

* Update documentation
  • Loading branch information
to-bar authored Feb 10, 2021
1 parent 5bdbd30 commit 0e0e0d6
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 172 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-0.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [#1888](https://github.com/epiphany-platform/epiphany/issues/1888) - epicli upgrade of cluster created by Epiphany v0.5 may fail
- [#2002](https://github.com/epiphany-platform/epiphany/issues/2002) - Do not install Filebeat when there is no Elasticsearch
- [#2042](https://github.com/epiphany-platform/epiphany/issues/2042) - PostgreSQL replication with repmgr: hot_standby not set in config file
- [#2041](https://github.com/epiphany-platform/epiphany/issues/2042) - Pgpool not showing Replication State on RedHat

### Updated

Expand Down
3 changes: 3 additions & 0 deletions core/src/epicli/data/common/ansible/playbooks/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
- hosts: postgresql
become: true
become_method: sudo
module_defaults:
shell:
executable: /bin/bash
roles:
- postgresql
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ data:
# Controls various backend behavior
# ALLOW_TO_FAILOVER, DISALLOW_TO_FAILOVER
# or ALWAYS_MASTER
backend_application_name{{ loop.index0 }} = 'repmgr'
backend_application_name{{ loop.index0 }} = '{{ hostvars[groups['postgresql'][loop.index0]].ansible_fqdn }}'
# walsender's application_name, used for "show pool_nodes" command
{% if not loop.last %}{# add empty line as node separator #}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pg_service_name:
RedHat: postgresql-10
Debian: postgresql

pg_instantiated_service_name:
RedHat: null
Debian: postgresql@10-main

pg_config_dir:
RedHat: /var/lib/pgsql/10/data
Debian: /etc/postgresql/10/main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
when:
- ansible_os_family == 'RedHat'

- name: Enable postgresql service
systemd:
name: "{{ pg_service_name[ansible_os_family] }}"
enabled: yes

- name: Change pg_hba.conf
replace:
path: "{{ pg_config_dir[ansible_os_family] }}/pg_hba.conf"
Expand Down Expand Up @@ -85,6 +80,17 @@
backup: yes
register: change_postgresql_conf

# Placed here to avoid errors in log due to nonexistent directory
- name: Create directory for archiving WAL files
file:
path: /dbbackup/{{ inventory_hostname }}/backup/
state: directory
owner: postgres
group: postgres
when:
- specification.extensions.replication.enabled is defined
- specification.extensions.replication.enabled | bool

- name: Restart postgresql service
systemd:
name: "{{ pg_service_name[ansible_os_family] }}"
Expand All @@ -93,13 +99,19 @@
or change_postgresql_epiphany_conf
or change_postgresql_conf

- name: Enable postgresql service
systemd:
name: "{{ pg_service_name[ansible_os_family] }}"
enabled: yes

- name: Configure logrotate
block:
- name: Remove logrotate configuration provided by 'postgresql-common' package
file:
path: /etc/logrotate.d/postgresql-common
state: absent
when: ansible_os_family == 'Debian'

- name: Create logrotate configuration file
template:
src: logrotate.conf.j2
Expand All @@ -112,15 +124,15 @@

- name: Set up replication
include_tasks: replication-{{ ansible_os_family }}.yml
when:
when:
- specification.extensions.replication.enabled is defined
- specification.extensions.replication.enabled
- specification.extensions.replication.use_repmgr is defined
- not specification.extensions.replication.use_repmgr

- name: Set up replication with repmgr
include_tasks: replication-repmgr-{{ ansible_os_family }}.yml
when:
when:
- specification.extensions.replication.enabled is defined
- specification.extensions.replication.enabled
- specification.extensions.replication.use_repmgr is defined
Expand Down
Loading

0 comments on commit 0e0e0d6

Please sign in to comment.