54 lines
1.3 KiB
YAML
54 lines
1.3 KiB
YAML
# Install a docker based mariadb.
|
|
---
|
|
- name: include secrets
|
|
include_vars:
|
|
file: ../../secrets.yml
|
|
name: secrets
|
|
|
|
- name: install service file.
|
|
template:
|
|
src: templates/mysql.service
|
|
dest: /etc/systemd/system/mysql.service
|
|
mode: 644
|
|
owner: root
|
|
group: root
|
|
|
|
- name: start service at boot.
|
|
command: systemctl reenable mysql.service
|
|
|
|
- name: make mariadb settings volume
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: 0777
|
|
with_items:
|
|
- /srv/mariadb/lib/mysql
|
|
- /srv/mariadb/etc/mysql
|
|
|
|
- name: place settings file
|
|
copy:
|
|
src: files/my.cnf
|
|
dest: /srv/mariadb/etc/mysql
|
|
mode: 660
|
|
|
|
- name: Set galara.cnf on first node if we have at least three nodes.
|
|
copy:
|
|
src: files/galera-master.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
|
|
|
|
- command: systemctl daemon-reload
|
|
|
|
- name: make sure service is started
|
|
systemd:
|
|
name: mysql.service
|
|
state: started
|