56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
---
|
|
|
|
- name: INCLUDE_VARS | Related to Debian version
|
|
include_vars: "{{ ansible_distribution_release }}.yml"
|
|
|
|
- name: STAT | Check if mysql exists
|
|
stat: path=/etc/init.d/mysql
|
|
register: mysql_exists
|
|
changed_when: false
|
|
|
|
- name: INCLUDE | Install
|
|
include: install.yml
|
|
|
|
- name: SERVICE | Ensure daemon is started
|
|
service: name=mysql state=started
|
|
|
|
- name: TEMPLATE | Deploy configuration
|
|
template: src=etc/mysql/my.cnf.j2 dest=/etc/mysql/my.cnf
|
|
register: config
|
|
|
|
- name: SERVICE | Restart now (prevent bugs)
|
|
service: name=mysql state=restarted
|
|
when: config.changed
|
|
|
|
- name: TEMPLATE | Deploy extra configuration
|
|
template: src=etc/mysql/conf.d/10-extra.cnf.j2 dest=/etc/mysql/conf.d/10-extra.cnf
|
|
notify: restart mysql
|
|
|
|
- name: TEMPLATE Create .my.cnf for root
|
|
template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes
|
|
|
|
- name: INCLUDE | Replication Master
|
|
include: replication_master.yml
|
|
when: mysql_replication_master
|
|
|
|
- name: INCLUDE | Replication slave
|
|
include: replication_slave.yml
|
|
when: mysql_replication_slave
|
|
|
|
- name: INCLUDE | Secure install
|
|
include: 'secure.yml'
|
|
|
|
- name: MYSQL_DB | Create databases
|
|
mysql_db: name={{ item }} state=present
|
|
with_items: mysql_databases
|
|
|
|
- name: MYSQL_USER | Manages users...
|
|
mysql_user: >
|
|
name={{ item.name }}
|
|
password={{ item.password }}
|
|
priv={{ item.priv }}
|
|
host={{ item.host | default('localhost') }}
|
|
state=present
|
|
with_items: mysql_users
|
|
|