Created
September 13, 2018 05:49
-
-
Save echo-devnull/dccbb486ffac94a29c17791dabf1fd5c to your computer and use it in GitHub Desktop.
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
--- | |
- hosts: percona | |
serial: 1 | |
# First we make sure the cluster is not in a weird state before we begin rebooting | |
# That would be bad. | |
pre_tasks: | |
# Right! Before we begin a reboot, first check if the cluster is green | |
- name: Wait for cluster to be Synced before we begin | |
shell: "echo \"SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';\" | mysql" | |
register: result | |
until: result.stdout.find("Synced") != -1 | |
retries: 200 | |
delay: 3 | |
become: yes | |
tasks: | |
# Right! Before we begin a reboot, first check if the cluster is green | |
- name: Wait for cluster to be Synced before we begin | |
shell: "echo \"SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';\" | mysql" | |
register: result | |
until: result.stdout.find("Synced") != -1 | |
retries: 200 | |
delay: 3 | |
become: yes | |
- name: Wait for cluster wsrep_ready to be ON | |
shell: "echo \"SHOW GLOBAL STATUS LIKE 'wsrep_ready';\" | mysql" | |
register: result | |
until: result.stdout.find("ON") != -1 | |
retries: 200 | |
delay: 3 | |
become: yes | |
- name: Wait for cluster wsrep_connected to be ON | |
shell: "echo \"SHOW GLOBAL STATUS LIKE 'wsrep_connected';\" | mysql" | |
register: result | |
until: result.stdout.find("ON") != -1 | |
retries: 200 | |
delay: 3 | |
become: yes | |
- name: Turn off mysql | |
service: | |
name: mysql | |
state: stopped | |
- name: Reboot the server | |
shell: "sleep 5 && reboot" | |
async: 1 | |
poll: 0 | |
- name: Wait 600 seconds for target connection to become reachable/usable | |
wait_for_connection: | |
connect_timeout: 20 | |
sleep: 5 | |
delay: 30 | |
timeout: 600 | |
- name: Wait for cluster to be Synced before we begin | |
shell: "echo \"SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';\" | mysql" | |
register: result | |
until: result.stdout.find("Synced") != -1 | |
retries: 200 | |
delay: 3 | |
become: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment