The galera cnf can be the same template across...

nodes.
This commit is contained in:
Egon Rijpkema
2017-10-18 09:23:04 +02:00
parent fdb5320429
commit 7218694901
5 changed files with 77 additions and 53 deletions

View File

@ -13,9 +13,6 @@
owner: root
group: root
- name: start service at boot.
command: systemctl reenable mysql.service
- name: make mariadb settings volume
file:
path: "{{ item }}"
@ -24,30 +21,35 @@
with_items:
- /srv/mariadb/lib/mysql
- /srv/mariadb/etc/mysql
- /srv/mariadb/etc/mysql/conf.d
- name: place settings file
copy:
src: files/my.cnf
dest: /srv/mariadb/etc/mysql
dest: /srv/mariadb/etc/mysql/conf.d/my.cnf
mode: 660
- name: Set galara.cnf on first node if we have at least three nodes.
copy:
src: files/galera-master.cnf
- name: Set galara.cnf on node if we have at least three nodes.
template:
src: files/galera.cnf
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
mode: 660
when: ansible_nodename == hostname_node0 and hostvars[groups['mariadb']]|length >= 3
- name: Set galara.cnf on other nodes if we have at least three nodes.
copy:
src: files/galera-slave.cnf
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
mode: 660
when: ansible_nodename != hostname_node0 and hostvars[groups['mariadb']]|length >= 3
when: groups['databases'] | length >= 3
- command: systemctl daemon-reload
- name: start service at boot.
command: systemctl reenable mysql.service
# This mimics galera_new_cluster.sh
- name: Initialize a new cluster.
command: systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster'
when: groups['databases'] | length >= 3 and ansible_hostname == hostname_node0
- name: make sure service is started
systemd:
name: mysql.service
state: started
- name: Prevent cluster re-initialization
command: systemctl set-environment _WSREP_NEW_CLUSTER=''