Skip to content

Commit

Permalink
Fix repmgrd service on Ubuntu (hitachienergy#2451)
Browse files Browse the repository at this point in the history
* Set 'daemonize=false' option

* Shorter test names

* Add test for 'repmgr service status'

* Update postgres user in sudoers file

* Remove 'repmgr standby follow' from sudoers

* Remove backslashes
  • Loading branch information
to-bar authored Jul 22, 2021
1 parent 97748a1 commit f99af04
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
/bin/systemctl restart {{ pg.service_name[ansible_os_family] }},
/bin/systemctl reload {{ pg.service_name[ansible_os_family] }},
/bin/systemctl start {{ repmgr.service_name[ansible_os_family] }},
/bin/systemctl stop {{ repmgr.service_name[ansible_os_family] }},
{{ repmgr.bin_dir[ansible_os_family] }}/repmgr standby follow
/bin/systemctl stop {{ repmgr.service_name[ansible_os_family] }}
validate: 'visudo -cf %s'

- name: Extensions | repmgr | Create super user in postgresql
Expand Down Expand Up @@ -94,18 +93,25 @@
group: postgres
when: template_repmgr_conf.dest != '/etc/repmgr.conf'

# For repmgr installed from Ubuntu package additional configuration is required before repmgrd is started as daemon
# For repmgr installed from Ubuntu package additional configuration is required before repmgrd is started as daemon,
# see https://repmgr.org/docs/5.2/repmgrd-daemon.html#REPMGRD-CONFIGURATION-DEBIAN-UBUNTU
- name: Extensions | repmgr | Set repmgr.conf file in /etc/default/repmgrd
replace:
path: /etc/default/repmgrd
regexp: "^#REPMGRD_CONF=\"/path/to/repmgr.conf\""
replace: "REPMGRD_CONF=\"{{ repmgr.config_dir[ansible_os_family] }}/repmgr.conf\""
regexp: ^#REPMGRD_CONF=\"/path/to/repmgr.conf\"
replace: REPMGRD_CONF="{{ repmgr.config_dir[ansible_os_family] }}/repmgr.conf"

- name: Extensions | repmgr | Enable repmgrd in /etc/default/repmgrd
replace:
path: /etc/default/repmgrd
regexp: "^[#]?REPMGRD_ENABLED=no"
replace: "REPMGRD_ENABLED=yes"
regexp: ^[#]?REPMGRD_ENABLED=no
replace: REPMGRD_ENABLED=yes

- name: Extensions | repmgr | Set 'daemonize=false' option in /etc/default/repmgrd
lineinfile:
path: /etc/default/repmgrd
regexp: ^[#]?REPMGRD_OPTS=
line: REPMGRD_OPTS="--daemonize=false"

# --- Configure primary node ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@
module_defaults:
yum: { lock_timeout: "{{ yum_lock_timeout }}" }

- name: repmgr for PG {{ pg_version }} | Update postgres user in sudoers file
lineinfile:
path: /etc/sudoers
regexp: "^postgres ALL=\\(ALL:ALL\\) NOPASSWD:"
line: >-
postgres ALL=(ALL:ALL) NOPASSWD:
/bin/systemctl start {{ upgrade_defaults.pg.service_name[ansible_os_family] }},
/bin/systemctl stop {{ upgrade_defaults.pg.service_name[ansible_os_family] }},
/bin/systemctl restart {{ upgrade_defaults.pg.service_name[ansible_os_family] }},
/bin/systemctl reload {{ upgrade_defaults.pg.service_name[ansible_os_family] }},
/bin/systemctl start {{ upgrade_defaults.repmgr.service_name[ansible_os_family] }},
/bin/systemctl stop {{ upgrade_defaults.repmgr.service_name[ansible_os_family] }}
validate: 'visudo -cf %s'

# Step: Update /etc/default/repmgrd
- name: repmgr for PG {{ pg_version }} | Set 'daemonize=false' option in /etc/default/repmgrd
lineinfile:
path: /etc/default/repmgrd
regexp: ^[#]?REPMGRD_OPTS=
line: REPMGRD_OPTS="--daemonize=false"
when: ansible_os_family == 'Debian'

# Step: systemctl daemon-reload
# Step: Restart PostgreSQL
- name: repmgr for PG {{ pg_version }} | Restart PostgreSQL service
Expand Down
Loading

0 comments on commit f99af04

Please sign in to comment.