-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update rejoin role to make it more automatic (needs testing)
Need to expand variables
- Loading branch information
Showing
6 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,46 @@ | ||
--- | ||
- name: Rejoin | ||
hosts: "{{ rejoin }}" | ||
hosts: localhost | ||
remote_user: ubuntu | ||
vars: | ||
# Old primary host that went down | ||
rejoin: # provide via cmd | ||
# New primary host after it was promoted | ||
primary: # provide via cmd | ||
# Old standby that will be promoted to primary | ||
standby: # provide via cmd | ||
|
||
roles: | ||
- role: rejoin | ||
tasks: | ||
- name: Promote standby | ||
ansible.builtin.include_role: | ||
name: rejoin | ||
tasks_from: promote.yml | ||
apply: | ||
delegate_to: "{{ standby }}" | ||
tags: "promote" | ||
|
||
- name: Perform IP switchover | ||
ansible.builtin.include_role: | ||
name: ostack | ||
tasks_from: move_floating_ip.yml | ||
vars: | ||
ostack_primary: "{{ primary }}" | ||
ostack_standby: "{{ standby }}" | ||
tags: "promote" | ||
|
||
# TODO: should this happen before or after rejoining the old primary | ||
- name: Restart LARD ingestion service | ||
ansible.builtin.systemd_service: | ||
name: lard_ingestion | ||
state: restarted | ||
become: true | ||
delegate_to: "{{ standby }}" | ||
tags: "promote" | ||
|
||
- name: Rejoin old primary | ||
ansible.builtin.include_role: | ||
name: rejoin | ||
tasks_from: rejoin.yml | ||
apply: | ||
delegate_to: "{{ primary }}" | ||
vars: | ||
rejoin_primary_ip: "{{ hostvars[primary].ansible_host }}" | ||
# TODO: this should be done via DNS once we have those set up | ||
rejoin_primary_ip: "{{ hostvars[standby].ansible_host }}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
rejoin_primary_ip: | ||
rejoin_ip: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
- name: Check cluster | ||
ansible.builtin.command: repmgr -f /etc/repmgr.conf cluster show | ||
become: true | ||
become_user: postgres | ||
register: cluster_status | ||
changed_when: false | ||
|
||
# TODO: check that primary says "unreachable"? | ||
- name: Print cluster status | ||
ansible.builtin.debug: | ||
msg: "{{ cluster_status }}" | ||
|
||
- name: Dry run of standby promotion | ||
ansible.builtin.command: repmgr -f /etc/repmgr.conf standby promote --dry-run | ||
become: true | ||
become_user: postgres | ||
changed_when: false | ||
register: dry_run_promote | ||
|
||
- name: Print result of dry-run | ||
ansible.builtin.debug: | ||
msg: "{{ dry_run_promote }}" | ||
|
||
# TODO: should postgres service be restarted? | ||
# TODO: check that primary says "failed"? | ||
- name: Promote standby | ||
ansible.builtin.command: repmgr -f /etc/repmgr.conf standby promote | ||
become: true | ||
become_user: postgres | ||
changed_when: true | ||
# TODO: this will keep crashing until the the IP alias is moved to the standby | ||
# So probably best to restart after the IP switch | ||
# - name: Start LARD ingestion service | ||
# ansible.builtin.systemd_service: | ||
# daemon_reload: true | ||
# name: lard_ingestion | ||
# state: restarted | ||
# enabled: true | ||
# become: true |
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
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