Rename mysql_ -> mariadb_

pull/29/head
Emilien Mantel 2018-03-17 17:28:54 +01:00
parent 859bafdb50
commit c72c3ac842
37 changed files with 263 additions and 260 deletions

View File

@ -27,27 +27,27 @@ None.
Role Variables Role Variables
-------------- --------------
- `mysql_origin`: origin of the package ("default" or "upstream") - `mariadb_origin`: origin of the package ("default" or "upstream")
- `mysql_vendor`: "mariadb", "mariadb\_galera" - `mariadb_vendor`: "mariadb", "mariadb\_galera"
### Configuration ### Configuration
- `mysql_root_password`: root password (should be protected with [vault](http://docs.ansible.com/playbooks_vault.html)) - `mariadb_root_password`: root password (should be protected with [vault](http://docs.ansible.com/playbooks_vault.html))
If you need a feature you can't configure, you can use this list. These config will go to `/etc/mysql/conf.d/01-extra`. If you need a feature you can't configure, you can use this list. These config will go to `/etc/mysql/conf.d/01-extra`.
- `mysql_extra_config`: key/value hash see [default vars file](defaults/main.yml) - `mariadb_extra_config`: key/value hash see [default vars file](defaults/main.yml)
### Databases ### Databases
- `mysql_databases`: list... - `mariadb_databases`: list...
### Users ### Users
Example: Example:
``` ```
mysql_users: mariadb_users:
- name: 'kiki' - name: 'kiki'
password: '123' password: '123'
priv: hihi.*:ALL priv: hihi.*:ALL
@ -58,10 +58,10 @@ Check "priv" syntax in [mysql\_user module documentation](http://docs.ansible.co
### Packaging ### Packaging
- `mysql_mariadb_version`: 10.0 / 10.1 / 10.2 - `mariadb_version`: 10.0 / 10.1 / 10.2
- `mysql_mariadb_repository`: MariaDB upstream APT repository (see: [MariaDB repositories tool](https://downloads.mariadb.org/mariadb/repositories)) - `mariadb_repository`: MariaDB upstream APT repository (see: [MariaDB repositories tool](https://downloads.mariadb.org/mariadb/repositories))
- `mysql_percona_repository`: Percona upstream APT repository (see: [Percona APT doc](http://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html)) - `mariadb_percona_repository`: Percona upstream APT repository (see: [Percona APT doc](http://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html))
- `mysql_use_percona_apt`: Force using Percona APT repository (useful when you want to use latest version of percona toolkits, xtrabackup... etc) - `mariadb_use_percona_apt`: Force using Percona APT repository (useful when you want to use latest version of percona toolkits, xtrabackup... etc)
Dependencies Dependencies
------------ ------------
@ -73,7 +73,7 @@ Example Playbook
- hosts: servers - hosts: servers
roles: roles:
- { role: HanXHX.mysql, mysql_origin: 'upstream', mysql_vendor: 'mariadb' } - { role: HanXHX.mysql, mariadb_origin: 'upstream', mariadb_vendor: 'mariadb' }
License License
------- -------

14
Vagrantfile vendored
View File

@ -16,13 +16,13 @@ Vagrant.configure("2") do |config|
cases = [ cases = [
# Debian Stretch # Debian Stretch
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['master'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mariadb_origin: 'default', mariadb_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['slave'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mariadb_origin: 'default', mariadb_vendor: 'mariadb' }, groups: ['slave'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['master'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mariadb_origin: 'upstream', mariadb_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['slave'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mariadb_origin: 'upstream', mariadb_vendor: 'mariadb' }, groups: ['slave'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '1'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mariadb_origin: 'upstream' }, groups: ['mariadbgalera', '1'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '2'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mariadb_origin: 'upstream' }, groups: ['mariadbgalera', '2'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '3'] }, { os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mariadb_origin: 'upstream' }, groups: ['mariadbgalera', '3'] },
] ]
cases.each_with_index do |opts,index| cases.each_with_index do |opts,index|

View File

@ -3,145 +3,145 @@
# ------------------------------------- # -------------------------------------
# Setup # Setup
# ------------------------------------- # -------------------------------------
mysql_origin: 'default' mariadb_origin: 'default'
mysql_vendor: 'mariadb' mariadb_vendor: 'mariadb'
mysql_root_password: 'change_me_NOW' mariadb_root_password: 'change_me_NOW'
mysql_notify_restart: true mariadb_notify_restart: true
mysql_upstream_apt_src: false mariadb_upstream_apt_src: false
mysql_manage_logrotate: true mariadb_manage_logrotate: true
# ------------------------------------- # -------------------------------------
# Configuration # Configuration
# ------------------------------------- # -------------------------------------
# MySQL configuration template # MySQL configuration template
mysql_config_template: 'etc/mysql/my.cnf.j2' mariadb_config_template: 'etc/mysql/my.cnf.j2'
# MySQL connection settings. # MySQL connection settings.
mysql_port: "3306" mariadb_port: "3306"
mysql_bind_address: '127.0.0.1' mariadb_bind_address: '127.0.0.1'
mysql_datadir: '/var/lib/mysql' mariadb_datadir: '/var/lib/mysql'
mysql_pid_file: '/var/run/mysqld/mysqld.pid' mariadb_pid_file: '/var/run/mysqld/mysqld.pid'
mysql_socket: '/var/run/mysqld/mysqld.sock' mariadb_socket: '/var/run/mysqld/mysqld.sock'
# Slow query log settings. # Slow query log settings.
mysql_slow_query_log_enabled: false mariadb_slow_query_log_enabled: false
mysql_slow_query_log_file: '/var/log/mysql/mysql_slow.log' mariadb_slow_query_log_file: '/var/log/mysql/mysql_slow.log'
mysql_slow_query_time: 2 mariadb_slow_query_time: 2
# Memory settings (default values optimized ~512MB RAM). # Memory settings (default values optimized ~512MB RAM).
mysql_key_buffer_size: '256M' mariadb_key_buffer_size: '256M'
mysql_max_allowed_packet: '64M' mariadb_max_allowed_packet: '64M'
mysql_table_open_cache: '256' mariadb_table_open_cache: '256'
mysql_sort_buffer_size: '1M' mariadb_sort_buffer_size: '1M'
mysql_read_buffer_size: '1M' mariadb_read_buffer_size: '1M'
mysql_read_rnd_buffer_size: '4M' mariadb_read_rnd_buffer_size: '4M'
mysql_myisam_sort_buffer_size: '64M' mariadb_myisam_sort_buffer_size: '64M'
mysql_thread_cache_size: '8' mariadb_thread_cache_size: '8'
mysql_query_cache_size: '16M' mariadb_query_cache_size: '16M'
# Other settings. # Other settings.
mysql_wait_timeout: 28800 mariadb_wait_timeout: 28800
# Try number of CPU's * 2 for thread_concurrency. # Try number of CPU's * 2 for thread_concurrency.
mysql_thread_concurrency: "{{ ansible_processor_cores * 2 }}" mariadb_thread_concurrency: "{{ ansible_processor_cores * 2 }}"
# InnoDB settings. # InnoDB settings.
mysql_innodb_file_per_table: '1' mariadb_innodb_file_per_table: '1'
mysql_innodb_buffer_pool_size: "{{ (ansible_memtotal_mb * 0.2) | round | int }}M" mariadb_innodb_buffer_pool_size: "{{ (ansible_memtotal_mb * 0.2) | round | int }}M"
mysql_innodb_log_file_size: "64M" # If this setting changes on a running system, you will break it! http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html mariadb_innodb_log_file_size: "64M" # If this setting changes on a running system, you will break it! http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html
mysql_innodb_log_buffer_size: '8M' mariadb_innodb_log_buffer_size: '8M'
mysql_innodb_flush_log_at_trx_commit: '1' mariadb_innodb_flush_log_at_trx_commit: '1'
mysql_innodb_lock_wait_timeout: 50 mariadb_innodb_lock_wait_timeout: 50
# mysqldump settings. # mysqldump settings.
mysql_mysqldump_max_allowed_packet: '64M' mariadb_mysqldump_max_allowed_packet: '64M'
# Logging settings. # Logging settings.
mysql_log_error: '/var/log/mysql/mysql_error.log' mariadb_log_error: '/var/log/mysql/mysql_error.log'
mysql_syslog_tag: 'mysql' mariadb_syslog_tag: 'mysql'
# ------------------------------------- # -------------------------------------
# Extra configuration # Extra configuration
# ------------------------------------- # -------------------------------------
# #
mysql_extra_configuration: {} mariadb_extra_configuration: {}
# Example: # Example:
#mysql_extra_configuration: #mariadb_extra_configuration:
# 'innodb_awsome_feature': 1 # 'innodb_awsome_feature': 1
# ------------------------------------- # -------------------------------------
# Replication # Replication
# ------------------------------------- # -------------------------------------
mysql_replication_master: false mariadb_replication_master: false
mysql_replication_slave: false mariadb_replication_slave: false
# This formula don't work with vagrant! All boxes have same default ip! # This formula don't work with vagrant! All boxes have same default ip!
mysql_server_id: "{{ ansible_default_ipv4.address | ipaddr('int') }}" mariadb_server_id: "{{ ansible_default_ipv4.address | ipaddr('int') }}"
mysql_replication_user: 'repl' mariadb_replication_user: 'repl'
mysql_replication_password: 'change_me_NOW' mariadb_replication_password: 'change_me_NOW'
mysql_replication_host: '192.168.0.1' mariadb_replication_host: '192.168.0.1'
mysql_replication_port: '3306' mariadb_replication_port: '3306'
mysql_backup_dir: '/var/backups/tmp-mysql' mariadb_backup_dir: '/var/backups/tmp-mysql'
# Master # Master
mysql_max_binlog_size: "100M" mariadb_max_binlog_size: "100M"
mysql_expire_logs_days: "10" mariadb_expire_logs_days: "10"
# #
# Slave # Slave
# #
mysql_slave_readonly: true mariadb_slave_readonly: true
# Import data from # Import data from
mysql_slave_import_data: true mariadb_slave_import_data: true
# host used to create a backup (can be the master or another slave) - default: use the master # host used to create a backup (can be the master or another slave) - default: use the master
mysql_slave_import_from: "{{ mysql_replication_host }}" mariadb_slave_import_from: "{{ mariadb_replication_host }}"
# Delete dump after slave configuration (set false if you have many slaves to install, it avoids to create many dumps) # Delete dump after slave configuration (set false if you have many slaves to install, it avoids to create many dumps)
mysql_slave_import_flush_dump: true mariadb_slave_import_flush_dump: true
# Slave uses mysql database from master? # Slave uses mysql database from master?
mysql_slave_replicate_mysqldb: true mariadb_slave_replicate_mysqldb: true
# Don't replicate these DBs/tables # Don't replicate these DBs/tables
mysql_slave_ignore_db: [] mariadb_slave_ignore_db: []
mysql_slave_ignore_table: [] mariadb_slave_ignore_table: []
# SSH user used to copy data # SSH user used to copy data
mysql_backup_user: "{{ ansible_user_id }}" # TODO: change var name mariadb_backup_user: "{{ ansible_user_id }}" # TODO: change var name
## If data is already imported, you can specify position ## If data is already imported, you can specify position
mysql_master_log_file: null mariadb_master_log_file: null
mysql_master_log_pos: null mariadb_master_log_pos: null
# If true, reconfigure slave # If true, reconfigure slave
mysql_slave_force_setup: false mariadb_slave_force_setup: false
mysql_gtid_domain_id: 1 mariadb_gtid_domain_id: 1
# ------------------------------------- # -------------------------------------
# Database / Users # Database / Users
# ------------------------------------- # -------------------------------------
mysql_databases: [] mariadb_databases: []
mysql_users: [] mariadb_users: []
# ------------------------------------- # -------------------------------------
# MariaDB # MariaDB
# ------------------------------------- # -------------------------------------
mysql_mariadb_version: '10.1' mariadb_version: '10.1'
mysql_mariadb_mirror_domain: "ftp.igh.cnrs.fr" mariadb_mirror_domain: "ftp.igh.cnrs.fr"
# See: https://downloads.mariadb.org/mariadb/repositories # See: https://downloads.mariadb.org/mariadb/repositories
mysql_mariadb_repository: "http://{{ mysql_mariadb_mirror_domain }}/pub/mariadb/repo/{{ mysql_mariadb_version }}/debian" mariadb_repository: "http://{{ mariadb_mirror_domain }}/pub/mariadb/repo/{{ mariadb_version }}/debian"
mysql_mariadb_key_server: "keyserver.ubuntu.com" mariadb_key_server: "keyserver.ubuntu.com"
mysql_mariadb_key_ids: ['0xcbcb082a1bb943db', '0xf1656f24c74cd1d8'] mariadb_key_ids: ['0xcbcb082a1bb943db', '0xf1656f24c74cd1d8']
# ------------------------------------- # -------------------------------------
# Galera # Galera
# ------------------------------------- # -------------------------------------
mysql_galera_resetup: false mariadb_galera_resetup: false
mysql_galera_members: [] mariadb_galera_members: []
mysql_galera_primary_node: 'change_me' # See: https://github.com/ansible/ansible/issues/17453 mariadb_galera_primary_node: 'change_me' # See: https://github.com/ansible/ansible/issues/17453
# ------------------------------------- # -------------------------------------
# Percona # Percona
# ------------------------------------- # -------------------------------------
mysql_percona_repository: 'http://repo.percona.com/apt' mariadb_percona_repository: 'http://repo.percona.com/apt'
mysql_use_percona_apt: false mariadb_use_percona_apt: false
mysql_install_xtrabackup_package: false mariadb_install_xtrabackup_package: false
mysql_xtrabackup_package: "{{ mysql_default_xtrabackup_package }}" mariadb_xtrabackup_package: "{{ mariadb_default_xtrabackup_package }}"

View File

@ -1,5 +1,7 @@
--- ---
- name: restart mysql - name: restart mariadb
action: service name=mysql state=restarted enabled=yes service:
when: mysql_notify_restart name: mysql
state: restarted
when: mariadb_notify_restart

View File

@ -1,6 +1,6 @@
--- ---
- set_fact: - set_fact:
booboo: "{{ mysql_datadir }}/.ansible_galera_boostrap" booboo: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
- name: STAT | Bootstrap mark - name: STAT | Bootstrap mark
stat: path={{ booboo }} stat: path={{ booboo }}
@ -9,7 +9,7 @@
- block: - block:
- name: SET_FACT | We must NOT restart after bootstrap! - name: SET_FACT | We must NOT restart after bootstrap!
set_fact: set_fact:
mysql_notify_restart: false mariadb_notify_restart: false
- name: SERVICE | Stop MariaDB - name: SERVICE | Stop MariaDB
service: name=mysql state=stopped service: name=mysql state=stopped
@ -26,7 +26,7 @@
register: bootstrap_run register: bootstrap_run
when: ansible_service_mgr != 'systemd' when: ansible_service_mgr != 'systemd'
when: not s.stat.exists or mysql_galera_resetup when: not s.stat.exists or mariadb_galera_resetup
- name: COMMAND | Create Bootstrap mark - name: COMMAND | Create Bootstrap mark
command: "touch {{ booboo }}" command: "touch {{ booboo }}"

View File

@ -6,16 +6,16 @@
- name: INCLUDE | Bootstrap first node - name: INCLUDE | Bootstrap first node
include: 'bootstrap.yml' include: 'bootstrap.yml'
when: inventory_hostname == mysql_galera_primary_node when: inventory_hostname == mariadb_galera_primary_node
- name: INCLUDE | Configure other nodes - name: INCLUDE | Configure other nodes
include: 'nodes.yml' include: 'nodes.yml'
when: inventory_hostname != mysql_galera_primary_node when: inventory_hostname != mariadb_galera_primary_node
- name: SERVICE | Restart MariaDB if needed - name: SERVICE | Restart MariaDB if needed
service: name=mysql state=restarted service: name=mysql state=restarted
when: > when: >
((galeraconfig or (p is defined and p.changed)) and ((galeraconfig or (p is defined and p.changed)) and
(bootstrap_run is not defined)) or (bootstrap_run is not defined)) or
((inventory_hostname != mysql_galera_primary_node) and ((inventory_hostname != mariadb_galera_primary_node) and
(mysql_galera_resetup)) (mariadb_galera_resetup))

View File

@ -3,7 +3,7 @@
- name: COMMAND | GET debian.cnf from primary node - name: COMMAND | GET debian.cnf from primary node
command: cat /etc/mysql/debian.cnf command: cat /etc/mysql/debian.cnf
register: debiancnf register: debiancnf
delegate_to: '{{ mysql_galera_primary_node }}' delegate_to: '{{ mariadb_galera_primary_node }}'
changed_when: false changed_when: false
- name: COMMAND | Get current debian.cnf - name: COMMAND | Get current debian.cnf

View File

@ -2,23 +2,23 @@
- name: INCLUDE | Use Percona repository - name: INCLUDE | Use Percona repository
include: 'percona/apt.yml' include: 'percona/apt.yml'
when: mysql_use_percona_apt when: mariadb_use_percona_apt
- name: INCLUDE | Install MariaDB from Debian repo - name: INCLUDE | Install MariaDB from Debian repo
include: 'mariadb/default.yml' include: 'mariadb/default.yml'
when: mysql_origin == 'default' and mysql_vendor == 'mariadb' when: mariadb_origin == 'default' and mariadb_vendor == 'mariadb'
- name: INCLUDE | Install MariaDB from MariaDB repo - name: INCLUDE | Install MariaDB from MariaDB repo
include: 'mariadb/upstream.yml' include: 'mariadb/upstream.yml'
when: mysql_origin == 'upstream' when: mariadb_origin == 'upstream'
- name: APT | Install few MySQL related tools - name: APT | Install few MySQL related tools
apt: apt:
pkg: "{{ item }}" pkg: "{{ item }}"
install_recommends: no install_recommends: no
with_items: "{{ mysql_tools }}" with_items: "{{ mariadb_tools }}"
- name: APT | Install percona-xtrabackup if needed - name: APT | Install percona-xtrabackup if needed
apt: apt:
pkg: "{{ mysql_xtrabackup_package }}" pkg: "{{ mariadb_xtrabackup_package }}"
when: mysql_install_xtrabackup_package when: mariadb_install_xtrabackup_package

View File

@ -6,16 +6,16 @@
changed_when: false changed_when: false
- name: DEBCONF | Prepare MariaDB silent installation (root password) - name: DEBCONF | Prepare MariaDB silent installation (root password)
debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password' vtype='password' value='{{ mysql_root_password }}' debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password' vtype='password' value='{{ mariadb_root_password }}'
when: not mysql_exists.stat.exists when: not mariadb_exists.stat.exists
- name: DEBCONF | Prepare MariaDB silent installation (root password again) - name: DEBCONF | Prepare MariaDB silent installation (root password again)
debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password_again' vtype='password' value='{{ mysql_root_password }}' debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password_again' vtype='password' value='{{ mariadb_root_password }}'
when: not mysql_exists.stat.exists when: not mariadb_exists.stat.exists
- name: APT | Install MariaDB server - name: APT | Install MariaDB server
apt: pkg=mariadb-server state=present apt: pkg=mariadb-server state=present
- name: APT | Install Galera - name: APT | Install Galera
apt: pkg=galera-3 state=present apt: pkg=galera-3 state=present
when: mysql_vendor == 'mariadb_galera' when: mariadb_vendor == 'mariadb_galera'

View File

@ -1,18 +1,18 @@
--- ---
- name: APT_KEY | Install MariaDB key - name: APT_KEY | Install MariaDB key
apt_key: keyserver="{{ mysql_mariadb_key_server }}" id={{ item }} state=present apt_key: keyserver="{{ mariadb_mariadb_key_server }}" id={{ item }} state=present
with_items: "{{ mysql_mariadb_key_ids }}" with_items: "{{ mariadb_mariadb_key_ids }}"
- name: TEMPLATE | Deploy APT pinning (prevent upgrades from Debian) - name: TEMPLATE | Deploy APT pinning (prevent upgrades from Debian)
template: src=etc/apt/preferences.d/95-mariadb.j2 dest=/etc/apt/preferences.d/95-mariadb template: src=etc/apt/preferences.d/95-mariadb.j2 dest=/etc/apt/preferences.d/95-mariadb
- name: APT_REPOSITORY | Add MariaDB repository - name: APT_REPOSITORY | Add MariaDB repository
apt_repository: repo='deb {{ mysql_mariadb_repository }} {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb {{ mariadb_mariadb_repository }} {{ ansible_distribution_release }} main' state=present
- name: APT_REPOSITORY | Add MariaDB (src) repository - name: APT_REPOSITORY | Add MariaDB (src) repository
apt_repository: repo='deb-src {{ mysql_mariadb_repository }} {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb-src {{ mariadb_mariadb_repository }} {{ ansible_distribution_release }} main' state=present
when: mysql_upstream_apt_src when: mariadb_upstream_apt_src
- name: INCLUDE | Normal Install - name: INCLUDE | Normal Install
include: default.yml include: default.yml

View File

@ -7,9 +7,9 @@
template: src=etc/apt/preferences.d/95-percona.j2 dest=/etc/apt/preferences.d/95-percona template: src=etc/apt/preferences.d/95-percona.j2 dest=/etc/apt/preferences.d/95-percona
- name: APT_REPOSITORY | Add Percona repository - name: APT_REPOSITORY | Add Percona repository
apt_repository: repo='deb {{ mysql_percona_repository }} {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb {{ mariadb_percona_repository }} {{ ansible_distribution_release }} main' state=present
- name: APT_RESPOSITORY | Add Percona (src) repository - name: APT_RESPOSITORY | Add Percona (src) repository
apt_repository: repo='deb-src {{ mysql_percona_repository }} {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb-src {{ mariadb_percona_repository }} {{ ansible_distribution_release }} main' state=present
when: mysql_upstream_apt_src when: mariadb_upstream_apt_src

View File

@ -4,15 +4,16 @@
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml" include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
- name: STAT | Check if mysql exists - name: STAT | Check if mysql exists
stat: path=/etc/init.d/mysql stat:
register: mysql_exists path: /usr/bin/mariadb
register: mariadb_exists
changed_when: false changed_when: false
- name: INCLUDE | Install - name: INCLUDE | Install
include: install/main.yml include: install/main.yml
- name: TEMPLATE | Deploy configuration - name: TEMPLATE | Deploy configuration
template: "src={{ mysql_config_template }} dest=/etc/mysql/my.cnf" template: "src={{ mariadb_config_template }} dest=/etc/mysql/my.cnf"
register: config register: config
- name: TEMPLATE | Deploy extra configuration - name: TEMPLATE | Deploy extra configuration
@ -23,18 +24,18 @@
service: name=mysql state=restarted service: name=mysql state=restarted
when: > when: >
(config.changed or extraconfig.changed) and (config.changed or extraconfig.changed) and
not mysql_galera_resetup not mariadb_galera_resetup
- name: TEMPLATE Create .my.cnf for root - name: TEMPLATE Create .my.cnf for root
template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes
- name: INCLUDE | Galera - name: INCLUDE | Galera
include: galera/main.yml include: galera/main.yml
when: mysql_vendor == 'mariadb_galera' when: mariadb_vendor == 'mariadb_galera'
- name: INCLUDE | Replication - name: INCLUDE | Replication
include: replication/main.yml include: replication/main.yml
when: mysql_replication_master or mysql_replication_slave when: mariadb_replication_master or mariadb_replication_slave
- name: INCLUDE | Secure install - name: INCLUDE | Secure install
include: 'secure.yml' include: 'secure.yml'
@ -44,7 +45,7 @@
- name: MYSQL_DB | Create databases - name: MYSQL_DB | Create databases
mysql_db: name={{ item }} state=present mysql_db: name={{ item }} state=present
with_items: "{{ mysql_databases }}" with_items: "{{ mariadb_databases }}"
- name: MYSQL_USER | Manages users... - name: MYSQL_USER | Manages users...
mysql_user: > mysql_user: >
@ -53,10 +54,10 @@
priv="{{ item.priv }}" priv="{{ item.priv }}"
host="{{ item.host | default('localhost') }}" host="{{ item.host | default('localhost') }}"
state=present state=present
with_items: "{{ mysql_users }}" with_items: "{{ mariadb_users }}"
- name: TEMPLATE | Deploy logrotate configuration - name: TEMPLATE | Deploy logrotate configuration
template: template:
src: "etc/logrotate.d/mysql-server.j2" src: "etc/logrotate.d/mysql-server.j2"
dest: "/etc/logrotate.d/mysql-server" dest: "/etc/logrotate.d/mysql-server"
when: mysql_manage_logrotate when: mariadb_manage_logrotate

View File

@ -2,9 +2,9 @@
- name: INCLUDE | Replication Master - name: INCLUDE | Replication Master
include: master.yml include: master.yml
when: mysql_replication_master when: mariadb_replication_master
- name: INCLUDE | Replication slave - name: INCLUDE | Replication slave
include: slave.yml include: slave.yml
when: mysql_replication_slave when: mariadb_replication_slave

View File

@ -4,4 +4,4 @@
template: > template: >
src=etc/mysql/conf.d/50-master.cnf.j2 src=etc/mysql/conf.d/50-master.cnf.j2
dest=/etc/mysql/conf.d/50-master.cnf dest=/etc/mysql/conf.d/50-master.cnf
notify: restart mysql notify: restart mariadb

View File

@ -2,13 +2,13 @@
- name: MYSQL_VARIABLES | Set read only - name: MYSQL_VARIABLES | Set read only
mysql_variables: variable=read_only value=ON mysql_variables: variable=read_only value=ON
when: mysql_slave_readonly when: mariadb_slave_readonly
- name: TEMPLATE | Deploy slave configuration - name: TEMPLATE | Deploy slave configuration
template: > template: >
src=etc/mysql/conf.d/51-slave.cnf.j2 src=etc/mysql/conf.d/51-slave.cnf.j2
dest=/etc/mysql/conf.d/51-slave.cnf dest=/etc/mysql/conf.d/51-slave.cnf
notify: restart mysql notify: restart mariadb
- name: MYSQL_REPLICATION | Get slave status - name: MYSQL_REPLICATION | Get slave status
mysql_replication: mode=getslave mysql_replication: mode=getslave
@ -17,19 +17,19 @@
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master - name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/ssh.yml include: slave/ssh.yml
when: mysql_slave_replicate_mysqldb or ((slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data) when: mariadb_slave_replicate_mysqldb or ((slave_status.failed is defined or not slave_status.Is_Slave) and mariadb_slave_import_data)
- name: INCLUDE | Import data - name: INCLUDE | Import data
include: slave/import_data.yml include: slave/import_data.yml
when: (slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data when: (slave_status.failed is defined or not slave_status.Is_Slave) and mariadb_slave_import_data
- name: INCLUDE | Configure replication - name: INCLUDE | Configure replication
include: slave/replication.yml include: slave/replication.yml
when: (slave_status.failed is defined or not slave_status.Is_Slave) or mysql_slave_force_setup when: (slave_status.failed is defined or not slave_status.Is_Slave) or mariadb_slave_force_setup
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master - name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/debiancnf.yml include: slave/debiancnf.yml
when: mysql_slave_replicate_mysqldb when: mariadb_slave_replicate_mysqldb
- name: MYSQL_REPLICATION | Get slave status - name: MYSQL_REPLICATION | Get slave status
mysql_replication: mode=getslave mysql_replication: mode=getslave

View File

@ -3,19 +3,19 @@
- name: FETCH | Get /etc/mysql/debian.cnf on master - name: FETCH | Get /etc/mysql/debian.cnf on master
fetch: > fetch: >
src=/etc/mysql/debian.cnf src=/etc/mysql/debian.cnf
dest=/tmp/{{ mysql_slave_import_from }}/debian.cnf dest=/tmp/{{ mariadb_slave_import_from }}/debian.cnf
flat=yes flat=yes
changed_when: false changed_when: false
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
- name: LOCAL_ACTION FILE | Secure fetched file - name: LOCAL_ACTION FILE | Secure fetched file
local_action: file path=/tmp/{{ mysql_slave_import_from }}/debian.cnf mode=0600 local_action: file path=/tmp/{{ mariadb_slave_import_from }}/debian.cnf mode=0600
become: no become: no
- name: COPY | Fetched file to /etc/mysql/debian.cnf - name: COPY | Fetched file to /etc/mysql/debian.cnf
copy: > copy: >
src=/tmp/{{ mysql_slave_import_from }}/debian.cnf src=/tmp/{{ mariadb_slave_import_from }}/debian.cnf
dest=/etc/mysql/debian.cnf dest=/etc/mysql/debian.cnf
owner=root group=root mode=0600 owner=root group=root mode=0600
notify: restart mysql notify: restart mariadb

View File

@ -2,22 +2,22 @@
# Doc: https://www.percona.com/doc/percona-xtrabackup/2.1/howtos/recipes_ibkx_gtid.html # Doc: https://www.percona.com/doc/percona-xtrabackup/2.1/howtos/recipes_ibkx_gtid.html
- name: WAIT_FOR | source data (prevent rsync bug) - TODO find another hack - name: WAIT_FOR | source data (prevent rsync bug) - TODO find another hack
wait_for: host={{ mysql_slave_import_from }} port=22 wait_for: host={{ mariadb_slave_import_from }} port=22
- name: COMMAND | Prepare backup another server - name: COMMAND | Prepare backup another server
command: innobackupex --no-timestamp {{ mysql_backup_dir }} creates={{ mysql_backup_dir }} command: innobackupex --no-timestamp {{ mariadb_backup_dir }} creates={{ mariadb_backup_dir }}
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
register: backup register: backup
- name: SHELL | Dump - name: SHELL | Dump
shell: innobackupex --apply-log {{ mysql_backup_dir }} shell: innobackupex --apply-log {{ mariadb_backup_dir }}
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
when: backup.changed when: backup.changed
- name: FILE | Remove mysql db from backup - name: FILE | Remove mysql db from backup
file: path={{ mysql_backup_dir }}/mysql state=absent file: path={{ mariadb_backup_dir }}/mysql state=absent
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
when: backup.changed and not mysql_slave_replicate_mysqldb when: backup.changed and not mariadb_slave_replicate_mysqldb
- name: MYSQL_VARIABLES | Get datadir - name: MYSQL_VARIABLES | Get datadir
mysql_variables: variable=datadir mysql_variables: variable=datadir
@ -25,20 +25,20 @@
- name: SET_FACT | related to mysql datadir - name: SET_FACT | related to mysql datadir
set_fact: set_fact:
mysql_mysql_datadir: "{{ datadir.msg }}" mariadb_mariadb_datadir: "{{ datadir.msg }}"
mysql_binlog_info: "{{ datadir.msg }}/xtrabackup_binlog_info" mariadb_binlog_info: "{{ datadir.msg }}/xtrabackup_binlog_info"
- name: SERVICE | Stop MySQL before importing data - name: SERVICE | Stop MySQL before importing data
service: name=mysql state=stopped service: name=mysql state=stopped
# TODO: add an "ignore warning" # TODO: add an "ignore warning"
- name: COMMAND | Sync backup to slave - TODO remove vagrant as static user (see why mysql_backup_user is not working) - name: COMMAND | Sync backup to slave - TODO remove vagrant as static user (see why mariadb_backup_user is not working)
shell: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mysql_backup_user }}@{{ mysql_slave_import_from }}:{{ mysql_backup_dir }}/ {{ mysql_mysql_datadir }}/" shell: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_mariadb_datadir }}/"
become: no become: no
- name: FILE | Re-apply owner - name: FILE | Re-apply owner
file: > file: >
path={{ mysql_mysql_datadir }} path={{ mariadb_mariadb_datadir }}
state=directory state=directory
owner=mysql owner=mysql
group=mysql group=mysql
@ -48,25 +48,25 @@
service: name=mysql state=started service: name=mysql state=started
- name: SHELL | Get master_log_file - name: SHELL | Get master_log_file
command: awk '{ print $1 }' {{ mysql_binlog_info }} command: awk '{ print $1 }' {{ mariadb_binlog_info }}
register: master_log_file register: master_log_file
- name: SHELL | Get master_log_pos - name: SHELL | Get master_log_pos
command: awk '{ print $2 }' {{ mysql_binlog_info }} command: awk '{ print $2 }' {{ mariadb_binlog_info }}
register: master_log_pos register: master_log_pos
- name: SHELL | Get master GTID - name: SHELL | Get master GTID
command: awk '{ print $3 }' {{ mysql_binlog_info }} command: awk '{ print $3 }' {{ mariadb_binlog_info }}
register: master_gtid register: master_gtid
- name: SET_FACT | master_log_file - name: SET_FACT | master_log_file
set_fact: set_fact:
mysql_master_log_file: "{{ master_log_file.stdout }}" mariadb_master_log_file: "{{ master_log_file.stdout }}"
mysql_master_log_pos: "{{ master_log_pos.stdout }}" mariadb_master_log_pos: "{{ master_log_pos.stdout }}"
mysql_master_gtid: "{{ master_gtid.stdout }}" mariadb_master_gtid: "{{ master_gtid.stdout }}"
- name: FILE | Delete dump - name: FILE | Delete dump
file: path={{ mysql_backup_dir }} state=absent file: path={{ mariadb_backup_dir }} state=absent
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
when: mysql_slave_import_flush_dump when: mariadb_slave_import_flush_dump

View File

@ -6,17 +6,17 @@
- name: MYSQL_REPLICATION | Configure master host - name: MYSQL_REPLICATION | Configure master host
mysql_replication: > mysql_replication: >
mode=changemaster mode=changemaster
master_host={{ mysql_replication_host }} master_host={{ mariadb_replication_host }}
master_port={{ mysql_replication_port }} master_port={{ mariadb_replication_port }}
master_user={{ mysql_replication_user }} master_user={{ mariadb_replication_user }}
master_password={{ mysql_replication_password }} master_password={{ mariadb_replication_password }}
- name: MYSQL_REPLICATION | Change master - name: MYSQL_REPLICATION | Change master
mysql_replication: > mysql_replication: >
mode=changemaster mode=changemaster
master_log_file={{ mysql_master_log_file }} master_log_file={{ mariadb_master_log_file }}
master_log_pos={{ mysql_master_log_pos }} master_log_pos={{ mariadb_master_log_pos }}
when: mysql_master_log_file is defined and mysql_master_log_pos is defined when: mariadb_master_log_file is defined and mariadb_master_log_pos is defined
- name: MYSQL_REPLICATION | Start slave - name: MYSQL_REPLICATION | Start slave
mysql_replication: mode=startslave mysql_replication: mode=startslave

View File

@ -12,8 +12,8 @@
- name: AUTHORIZED_KEY | Auth slave to backup host - name: AUTHORIZED_KEY | Auth slave to backup host
authorized_key: authorized_key:
user: "{{ mysql_backup_user }}" user: "{{ mariadb_backup_user }}"
state: present state: present
key: "{{ pub_key.stdout }}" key: "{{ pub_key.stdout }}"
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
become: yes become: yes

View File

@ -1,7 +1,7 @@
--- ---
- name: MYSQL_USER | Update mysql root password for all root accounts - name: MYSQL_USER | Update mysql root password for all root accounts
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} mysql_user: name=root host={{ item }} password={{ mariadb_root_password }}
with_items: with_items:
- "{{ ansible_hostname }}" - "{{ ansible_hostname }}"
- 127.0.0.1 - 127.0.0.1

View File

@ -2,5 +2,5 @@
Explanation: Prevent Debian upgrades on mariadb packages Explanation: Prevent Debian upgrades on mariadb packages
Package: * Package: *
Pin: origin {{ mysql_mariadb_mirror_domain }} Pin: origin {{ mariadb_mariadb_mirror_domain }}
Pin-Priority: 1000 Pin-Priority: 1000

View File

@ -6,7 +6,7 @@
# flush-logs'd only once. # flush-logs'd only once.
# Else the binary logs would automatically increase by n times every day. # Else the binary logs would automatically increase by n times every day.
# - The error log is obsolete, messages go to syslog now. # - The error log is obsolete, messages go to syslog now.
{{ mysql_log_error }} {% if mysql_slow_query_log_enabled %}{{ mysql_slow_query_log_file }}{% endif %} { {{ mariadb_log_error }} {% if mariadb_slow_query_log_enabled %}{{ mariadb_slow_query_log_file }}{% endif %} {
daily daily
rotate 7 rotate 7
missingok missingok

View File

@ -11,14 +11,14 @@
# Global # Global
wsrep_on=ON wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://{{ mysql_galera_members | join(",") }} wsrep_cluster_address=gcomm://{{ mariadb_galera_members | join(",") }}
# TODO: https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_sst_method # TODO: https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_sst_method
wsrep_sst_method=rsync wsrep_sst_method=rsync
# TODO: wsrep_cluster_name="my_wsrep_cluster" # TODO: wsrep_cluster_name="my_wsrep_cluster"
# Node Configuration # Node Configuration
wsrep_node_address="{{ mysql_wsrep_node_address | default(ansible_default_ipv4.address) }}" wsrep_node_address="{{ mariadb_wsrep_node_address | default(ansible_default_ipv4.address) }}"
wsrep_node_name="{{ mysql_wsrep_node_name | default(ansible_fqdn) }}" wsrep_node_name="{{ mariadb_wsrep_node_name | default(ansible_fqdn) }}"
# -------------------- # --------------------

View File

@ -3,7 +3,7 @@
# ------------------------------------------- # -------------------------------------------
[mysqld] [mysqld]
{% for key, value in mysql_extra_configuration.items() %} {% for key, value in mariadb_extra_configuration.items() %}
{% if value is defined or value is not none %} {% if value is defined or value is not none %}
{{ key }} = {{ value }} {{ key }} = {{ value }}
{% else %} {% else %}

View File

@ -6,11 +6,11 @@
# Replication master # Replication master
[mysqld] [mysqld]
server_id={{ mysql_server_id }} server_id={{ mariadb_server_id }}
log_bin = mysql-bin log_bin = mysql-bin
log-bin-index = mysql-bin.index log-bin-index = mysql-bin.index
expire_logs_days = {{ mysql_expire_logs_days }} expire_logs_days = {{ mariadb_expire_logs_days }}
max_binlog_size = {{ mysql_max_binlog_size }} max_binlog_size = {{ mariadb_max_binlog_size }}
gtid_domain_id={{ mysql_gtid_domain_id }} gtid_domain_id={{ mariadb_gtid_domain_id }}
; vim: set ft=dosini : ; vim: set ft=dosini :

View File

@ -6,19 +6,19 @@
# Replication slave # Replication slave
[mysqld] [mysqld]
server_id={{ mysql_server_id }} server_id={{ mariadb_server_id }}
{% if mysql_slave_readonly %} {% if mariadb_slave_readonly %}
read-only read-only
{% endif %} {% endif %}
# --> Ignore DB/tables # --> Ignore DB/tables
{% if not mysql_slave_replicate_mysqldb %} {% if not mariadb_slave_replicate_mysqldb %}
replicate-ignore-db=mysql replicate-ignore-db=mysql
{% endif %} {% endif %}
{% for db in mysql_slave_ignore_db %} {% for db in mariadb_slave_ignore_db %}
replicate-ignore-db={{ db }} replicate-ignore-db={{ db }}
{% endfor %} {% endfor %}
{% for t in mysql_slave_ignore_table %} {% for t in mariadb_slave_ignore_table %}
replicate-ignore-table={{ t }} replicate-ignore-table={{ t }}
{% endfor %} {% endfor %}
# <-- Ignore DB/tables # <-- Ignore DB/tables

View File

@ -3,29 +3,29 @@
# #
[client] [client]
port = {{ mysql_port }} port = {{ mariadb_port }}
socket = {{ mysql_socket }} socket = {{ mariadb_socket }}
[mysqld] [mysqld]
port = {{ mysql_port }} port = {{ mariadb_port }}
bind-address = {{ mysql_bind_address }} bind-address = {{ mariadb_bind_address }}
datadir = {{ mysql_datadir }} datadir = {{ mariadb_datadir }}
socket = {{ mysql_socket }} socket = {{ mariadb_socket }}
{# TODO: FIX later #} {# TODO: FIX later #}
# Logging configuration. # Logging configuration.
{% if mysql_log_error == 'syslog' %} {% if mariadb_log_error == 'syslog' %}
syslog syslog
syslog-tag = {{ mysql_syslog_tag }} syslog-tag = {{ mariadb_syslog_tag }}
{% else %} {% else %}
log-error = {{ mysql_log_error }} log-error = {{ mariadb_log_error }}
{% endif %} {% endif %}
{% if mysql_slow_query_log_enabled %} {% if mariadb_slow_query_log_enabled %}
# Slow query log configuration. # Slow query log configuration.
slow_query_log = 1 slow_query_log = 1
slow_query_log_file = {{ mysql_slow_query_log_file }} slow_query_log_file = {{ mariadb_slow_query_log_file }}
long_query_time = {{ mysql_slow_query_time }} long_query_time = {{ mariadb_slow_query_time }}
{% endif %} {% endif %}
# Disabling symbolic-links is recommended to prevent assorted security risks # Disabling symbolic-links is recommended to prevent assorted security risks
@ -38,39 +38,39 @@ user = mysql
;performance_schema ;performance_schema
# Memory settings. # Memory settings.
key_buffer_size = {{ mysql_key_buffer_size }} key_buffer_size = {{ mariadb_key_buffer_size }}
max_allowed_packet = {{ mysql_max_allowed_packet }} max_allowed_packet = {{ mariadb_max_allowed_packet }}
table_open_cache = {{ mysql_table_open_cache }} table_open_cache = {{ mariadb_table_open_cache }}
sort_buffer_size = {{ mysql_sort_buffer_size }} sort_buffer_size = {{ mariadb_sort_buffer_size }}
read_buffer_size = {{ mysql_read_buffer_size }} read_buffer_size = {{ mariadb_read_buffer_size }}
read_rnd_buffer_size = {{ mysql_read_rnd_buffer_size }} read_rnd_buffer_size = {{ mariadb_read_rnd_buffer_size }}
myisam_sort_buffer_size = {{ mysql_myisam_sort_buffer_size }} myisam_sort_buffer_size = {{ mariadb_myisam_sort_buffer_size }}
thread_cache_size = {{ mysql_thread_cache_size }} thread_cache_size = {{ mariadb_thread_cache_size }}
query_cache_size = {{ mysql_query_cache_size }} query_cache_size = {{ mariadb_query_cache_size }}
# Other settings. # Other settings.
wait_timeout = {{ mysql_wait_timeout }} wait_timeout = {{ mariadb_wait_timeout }}
# Try number of CPU's * 2 for thread_concurrency. # Try number of CPU's * 2 for thread_concurrency.
thread_concurrency = {{ mysql_thread_concurrency }} thread_concurrency = {{ mariadb_thread_concurrency }}
# InnoDB settings. # InnoDB settings.
innodb_file_per_table = {{ mysql_innodb_file_per_table }} innodb_file_per_table = {{ mariadb_innodb_file_per_table }}
innodb_buffer_pool_size = {{ mysql_innodb_buffer_pool_size }} innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
innodb_log_buffer_size = {{ mysql_innodb_log_buffer_size }} innodb_log_buffer_size = {{ mariadb_innodb_log_buffer_size }}
innodb_flush_log_at_trx_commit = {{ mysql_innodb_flush_log_at_trx_commit }} innodb_flush_log_at_trx_commit = {{ mariadb_innodb_flush_log_at_trx_commit }}
innodb_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }} innodb_lock_wait_timeout = {{ mariadb_innodb_lock_wait_timeout }}
{# If this setting changes on a running system, you will break it! #} {# If this setting changes on a running system, you will break it! #}
{# See how tho change it here: http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html #} {# See how tho change it here: http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html #}
{# TODO FIX -> Maybe detect a change and fail, just to be safe? #} {# TODO FIX -> Maybe detect a change and fail, just to be safe? #}
innodb_log_file_size = {{ mysql_innodb_log_file_size }} innodb_log_file_size = {{ mariadb_innodb_log_file_size }}
[mysqldump] [mysqldump]
quick quick
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }} max_allowed_packet = {{ mariadb_mysqldump_max_allowed_packet }}
[mysqld_safe] [mysqld_safe]
pid-file = {{ mysql_pid_file }} pid-file = {{ mariadb_pid_file }}
# #
# * IMPORTANT: Additional settings that can override those from this file! # * IMPORTANT: Additional settings that can override those from this file!

View File

@ -4,4 +4,4 @@
[client] [client]
user=root user=root
password="{{ mysql_root_password }}" password="{{ mariadb_root_password }}"

View File

@ -1,6 +1,6 @@
mysql_bind_address: '0.0.0.0' mariadb_bind_address: '0.0.0.0'
mysql_extra_configuration: mariadb_extra_configuration:
innodb_commit_concurrency: 0 innodb_commit_concurrency: 0
mysql_use_percona_apt: true mariadb_use_percona_apt: true
mysql_install_xtrabackup_package: true mariadb_install_xtrabackup_package: true
mysql_slow_query_log_enabled: true mariadb_slow_query_log_enabled: true

View File

@ -1,5 +1,5 @@
mysql_vendor: 'mariadb_galera' mariadb_vendor: 'mariadb_galera'
mysql_galera_members: mariadb_galera_members:
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1' - '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-2' - '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-2'
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-3' - '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-3'

View File

@ -1,18 +1,18 @@
# Master durability # Master durability
mysql_sync_binlog: '1' mariadb_sync_binlog: '1'
mysql_innodb_flush_log_at_trx_commit: '1' mariadb_innodb_flush_log_at_trx_commit: '1'
mysql_databases: mariadb_databases:
- 'testrepl' - 'testrepl'
- 'norepl' - 'norepl'
mysql_users: mariadb_users:
- name: 'replication' - name: 'replication'
password: '1a2b3c' password: '1a2b3c'
priv: '*.*:REPLICATION SLAVE' priv: '*.*:REPLICATION SLAVE'
host: '%' host: '%'
mysql_replication_master: true mariadb_replication_master: true
mysql_replication_slave: false mariadb_replication_slave: false
mysql_server_id: 1 mariadb_server_id: 1
# vim: set ft=yaml : # vim: set ft=yaml :

View File

@ -1 +1 @@
mysql_vendor: 'mysql' mariadb_vendor: 'mysql'

View File

@ -1,8 +1,8 @@
mysql_replication_master: false mariadb_replication_master: false
mysql_replication_slave: true mariadb_replication_slave: true
mysql_replication_user: 'replication' mariadb_replication_user: 'replication'
mysql_replication_password: '1a2b3c' mariadb_replication_password: '1a2b3c'
mysql_server_id: 2 mariadb_server_id: 2
mysql_slave_ignore_db: ['norepl'] mariadb_slave_ignore_db: ['norepl']
# vim: set ft=yaml : # vim: set ft=yaml :

View File

@ -27,18 +27,18 @@
changed_when: false changed_when: false
- set_fact: - set_fact:
# MySQL don't read /etc/hosts (from vagrant host plugin) # MySQL don't read /etc/hosts (from vagrant host plugin)
mysql_replication_host: "{{ ip.stdout }}" mariadb_replication_host: "{{ ip.stdout }}"
# Need this to use vagrant 'delegate_to' # Need this to use vagrant 'delegate_to'
mysql_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}" mariadb_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
roles: roles:
- ../../ - ../../
tasks: tasks:
- copy: src=import2.sql dest=/tmp/import2.sql - copy: src=import2.sql dest=/tmp/import2.sql
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
register: c register: c
- mysql_db: name={{ item }} state=import target=/tmp/import2.sql - mysql_db: name={{ item }} state=import target=/tmp/import2.sql
with_items: ['testrepl', 'norepl'] with_items: ['testrepl', 'norepl']
delegate_to: "{{ mysql_slave_import_from }}" delegate_to: "{{ mariadb_slave_import_from }}"
when: c.changed when: c.changed
- mysql_replication: mode=getslave - mysql_replication: mode=getslave
register: slave register: slave
@ -47,12 +47,12 @@
- hosts: mariadbgalera - hosts: mariadbgalera
vars: vars:
mysql_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1' mariadb_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
mysql_wsrep_node_address: "{{ ansible_all_ipv4_addresses[0] }}" mariadb_wsrep_node_address: "{{ ansible_all_ipv4_addresses[0] }}"
mysql_mariadb_version: '10.1' mariadb_mariadb_version: '10.1'
pre_tasks: pre_tasks:
- set_fact: - set_fact:
mysql_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}" mariadb_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
when: not is_docker when: not is_docker
roles: roles:
- ../../ - ../../

View File

@ -12,10 +12,10 @@ set -ev
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
# Check role # Check role
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK ansible-playbook -i $INVENTORY_FILE -c local -e "{ mariadb_vendor: $VENDOR, mariadb_origin: $ORIGIN }" --sudo -vv $PLAYBOOK
# Check indempotence # Check indempotence
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK > idempot.txt ansible-playbook -i $INVENTORY_FILE -c local -e "{ mariadb_vendor: $VENDOR, mariadb_origin: $ORIGIN }" --sudo -vv $PLAYBOOK > idempot.txt
grep -q 'changed=0.*failed=0' idempot.txt \ grep -q 'changed=0.*failed=0' idempot.txt \
&& (echo 'Idempotence test: pass' && exit 0) \ && (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: FAIL' && cat idempot.txt && exit 1) || (echo 'Idempotence test: FAIL' && cat idempot.txt && exit 1)

View File

@ -2,11 +2,11 @@
- hosts: all - hosts: all
vars: vars:
mysql_replication_master: true mariadb_replication_master: true
mysql_bind_address: '{{ ansible_eth0.ipv4.address }}' mariadb_bind_address: '{{ ansible_eth0.ipv4.address }}'
mysql_galera_members: mariadb_galera_members:
- '{{ ansible_eth0.ipv4.address }}' - '{{ ansible_eth0.ipv4.address }}'
mysql_galera_primary_node: 'localhost' mariadb_galera_primary_node: 'localhost'
roles: roles:
- ../../ - ../../
post_tasks: post_tasks:

View File

@ -1,6 +1,6 @@
mysql_tools: mariadb_tools:
- percona-toolkit - percona-toolkit
- python-mysqldb - python-mysqldb
- mysqltuner - mysqltuner
mysql_default_xtrabackup_package: 'percona-xtrabackup-24' mariadb_default_xtrabackup_package: 'percona-xtrabackup-24'