--- - name: "Uninstall xtrabackup utility (switched to mariabackup)" apt: name: percona-xtrabackup state: absent - name: "Remove tuning configuration file which is now merged with galera.cnf" file: path: /etc/mysql/conf.d/tuning.cnf state: absent - name: "Check if the galera config already exists" stat: path: /etc/mysql/conf.d/galera.cnf register: galera_cnf - name: "Configure /etc/mysql/conf.d/galera.cnf" template: src: galera.cnf.j2 dest: /etc/mysql/conf.d/galera.cnf owner: root group: mysql mode: 0640 tags: - config # TODO Check if we want this back or done in some other way. # It's safer to not be meddling with starting and stopping galera # nodes on subsequent runs. Registering in a file that the # initialization has been executed might already do the trick. # #- name: "Check if the node is safe for galera bootstrapping" # shell: "egrep -s -q '^ *safe_to_bootstrap *: *1 *$' /var/lib/mysql/grastate.dat" # register: grastate # failed_when: grastate.rc not in [0, 1, 2] # when: is_primary # # # state 0 = grastate.dat file exists and it contains "safe_to_bootstrap: 1" # # state 1 = grastate.dat file exists, but it does not contain "safe_to_bootstrap: 1" # # state 2 = grastate.dat file does not yet exist, this is a new node #- name: "Stop mysql service on primary node, prior to bootstrapping galera" # service: # name: mariadb # state: stopped # when: is_primary and grastate.rc in [0, 2] # #- name: "Bootstrap galera on primary node" # shell: galera_new_cluster # when: is_primary and grastate.rc in [0, 2] # #- name: "Restart mysql service on secondary node" # service: # name: mariadb # state: restarted # when: not is_primary - name: "Create galera-haproxy user (for checking node health)" mysql_user: name: galera-haproxy host: "%" - name: "Restart mysql server (only on initial install)" service: name: mariadb state: restarted when: not galera_cnf.stat.exists