2017-04-25 14:47:04 +02:00
|
|
|
# Install a docker based mariadb.
|
|
|
|
---
|
2017-08-14 16:40:06 +02:00
|
|
|
- name: include secrets
|
|
|
|
include_vars:
|
|
|
|
file: ../../secrets.yml
|
|
|
|
name: secrets
|
|
|
|
|
2017-06-22 09:19:08 +02:00
|
|
|
- name: make mariadb settings volume
|
|
|
|
file:
|
2017-08-02 15:22:10 +02:00
|
|
|
path: "{{ item }}"
|
2017-06-22 09:19:08 +02:00
|
|
|
state: directory
|
|
|
|
mode: 0777
|
2017-08-02 15:22:10 +02:00
|
|
|
with_items:
|
|
|
|
- /srv/mariadb/lib/mysql
|
|
|
|
- /srv/mariadb/etc/mysql
|
2017-08-31 15:02:47 +02:00
|
|
|
- /srv/mariadb/etc/mysql/conf.d
|
2017-06-22 09:19:08 +02:00
|
|
|
|
|
|
|
- name: place settings file
|
|
|
|
copy:
|
|
|
|
src: files/my.cnf
|
2017-08-31 15:02:47 +02:00
|
|
|
dest: /srv/mariadb/etc/mysql/conf.d/my.cnf
|
2017-06-22 09:19:08 +02:00
|
|
|
mode: 660
|
|
|
|
|
2017-08-31 15:02:47 +02:00
|
|
|
- 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: groups['databases'] | length >= 3
|
|
|
|
|
|
|
|
# This mimics galera_new_cluster.sh
|
|
|
|
- name: Initialize a new cluster.
|
|
|
|
block:
|
|
|
|
- set_fact:
|
|
|
|
mariadb_args: "--wsrep-new-cluster"
|
|
|
|
|
|
|
|
- template:
|
|
|
|
src: templates/mysql.service
|
|
|
|
dest: /etc/systemd/system/mysql.service
|
|
|
|
mode: 644
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- command: systemctl daemon-reload
|
|
|
|
|
|
|
|
- systemd:
|
|
|
|
name: mysql.service
|
|
|
|
state: started
|
|
|
|
|
|
|
|
when: groups['databases'] | length >= 3 and ansible_hostname == hostname_node0
|
|
|
|
|
|
|
|
- name: install service file.
|
|
|
|
block:
|
|
|
|
- set_fact:
|
|
|
|
mariadb_args: ""
|
|
|
|
- template:
|
|
|
|
src: templates/mysql.service
|
|
|
|
dest: /etc/systemd/system/mysql.service
|
|
|
|
mode: 644
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- name: Give the master node some time to initialize the cluster.
|
|
|
|
command: bash -c "sleep 60 && systemctl daemon-reload"
|
2017-06-22 09:19:08 +02:00
|
|
|
|
2017-04-25 14:47:04 +02:00
|
|
|
- name: make sure service is started
|
|
|
|
systemd:
|
|
|
|
name: mysql.service
|
|
|
|
state: started
|
2017-08-31 15:02:47 +02:00
|
|
|
|
|
|
|
- name: start service at boot.
|
|
|
|
command: systemctl reenable mysql.service
|
2018-02-28 10:36:17 +01:00
|
|
|
|
|
|
|
- name: Give the cluster some time to initialize replication.
|
|
|
|
command: bash -c "sleep 60 && systemctl daemon-reload"
|
|
|
|
when: groups['databases'] | length >= 3
|
|
|
|
|