Check if this role is deployed as part of the cluster
This makes it possible to deploy a galara cluster in one set of hosts and a separate stand alone mariadb on another host.
This commit is contained in:
parent
ca6adb44f6
commit
0c605af3ae
@ -11,9 +11,9 @@
|
|||||||
state: directory
|
state: directory
|
||||||
mode: 0777
|
mode: 0777
|
||||||
with_items:
|
with_items:
|
||||||
- /srv/mariadb/lib/mysql
|
- /srv/mariadb/lib/mysql
|
||||||
- /srv/mariadb/etc/mysql
|
- /srv/mariadb/etc/mysql
|
||||||
- /srv/mariadb/etc/mysql/conf.d
|
- /srv/mariadb/etc/mysql/conf.d
|
||||||
|
|
||||||
- name: place settings file
|
- name: place settings file
|
||||||
copy:
|
copy:
|
||||||
@ -21,12 +21,14 @@
|
|||||||
dest: /srv/mariadb/etc/mysql/conf.d/my.cnf
|
dest: /srv/mariadb/etc/mysql/conf.d/my.cnf
|
||||||
mode: 660
|
mode: 660
|
||||||
|
|
||||||
- name: Set galara.cnf on node if we have at least three nodes.
|
- name: >
|
||||||
|
Set galara.cnf on node if we have at least three nodes.
|
||||||
|
And we're part of the cluster.
|
||||||
template:
|
template:
|
||||||
src: files/galera.cnf
|
src: files/galera.cnf
|
||||||
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
|
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
|
||||||
mode: 660
|
mode: 660
|
||||||
when: groups['databases'] | length >= 3
|
when: "'databases' in group_names and groups['databases'] | length >= 3"
|
||||||
|
|
||||||
# This mimics galera_new_cluster.sh
|
# This mimics galera_new_cluster.sh
|
||||||
- name: Initialize a new cluster.
|
- name: Initialize a new cluster.
|
||||||
@ -47,7 +49,8 @@
|
|||||||
name: mysql.service
|
name: mysql.service
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
when: groups['databases'] | length >= 3 and ansible_hostname == hostname_node0
|
when: "'databases' in group_names and groups['databases'] \
|
||||||
|
| length >= 3 and ansible_hostname == hostname_node0"
|
||||||
|
|
||||||
- name: install service file.
|
- name: install service file.
|
||||||
block:
|
block:
|
||||||
@ -61,12 +64,22 @@
|
|||||||
group: root
|
group: root
|
||||||
|
|
||||||
- name: Give the master node some time to initialize the cluster.
|
- name: Give the master node some time to initialize the cluster.
|
||||||
command: bash -c "sleep 60 && systemctl daemon-reload"
|
command: bash -c "sleep 60"
|
||||||
|
when: "'databases' in group_names and groups['databases'] \
|
||||||
|
| length >= 3"
|
||||||
|
|
||||||
|
- name: Daemon reload (the implicit doesn't work)
|
||||||
|
command: bash -c "systemctl daemon-reload"
|
||||||
|
|
||||||
- name: make sure service is started
|
- name: make sure service is started
|
||||||
systemd:
|
systemd:
|
||||||
name: mysql.service
|
name: mysql.service
|
||||||
state: started
|
state: started
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
- name: start service at boot.
|
- name: start service at boot.
|
||||||
command: systemctl reenable mysql.service
|
command: systemctl reenable mysql.service
|
||||||
|
|
||||||
|
- name: Give the cluster some time to initialize replication.
|
||||||
|
command: bash -c "sleep 60 && systemctl daemon-reload"
|
||||||
|
when: "'databases' in group_names and groups['databases'] | length >= 3"
|
||||||
|
Loading…
Reference in New Issue
Block a user