Rename mysql_ -> mariadb_
parent
859bafdb50
commit
c72c3ac842
22
README.md
22
README.md
|
@ -27,27 +27,27 @@ None.
|
|||
Role Variables
|
||||
--------------
|
||||
|
||||
- `mysql_origin`: origin of the package ("default" or "upstream")
|
||||
- `mysql_vendor`: "mariadb", "mariadb\_galera"
|
||||
- `mariadb_origin`: origin of the package ("default" or "upstream")
|
||||
- `mariadb_vendor`: "mariadb", "mariadb\_galera"
|
||||
|
||||
### 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`.
|
||||
|
||||
- `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
|
||||
|
||||
- `mysql_databases`: list...
|
||||
- `mariadb_databases`: list...
|
||||
|
||||
### Users
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
mysql_users:
|
||||
mariadb_users:
|
||||
- name: 'kiki'
|
||||
password: '123'
|
||||
priv: hihi.*:ALL
|
||||
|
@ -58,10 +58,10 @@ Check "priv" syntax in [mysql\_user module documentation](http://docs.ansible.co
|
|||
|
||||
### Packaging
|
||||
|
||||
- `mysql_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))
|
||||
- `mysql_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_version`: 10.0 / 10.1 / 10.2
|
||||
- `mariadb_repository`: MariaDB upstream APT repository (see: [MariaDB repositories tool](https://downloads.mariadb.org/mariadb/repositories))
|
||||
- `mariadb_percona_repository`: Percona upstream APT repository (see: [Percona APT doc](http://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html))
|
||||
- `mariadb_use_percona_apt`: Force using Percona APT repository (useful when you want to use latest version of percona toolkits, xtrabackup... etc)
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
@ -73,7 +73,7 @@ Example Playbook
|
|||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: HanXHX.mysql, mysql_origin: 'upstream', mysql_vendor: 'mariadb' }
|
||||
- { role: HanXHX.mysql, mariadb_origin: 'upstream', mariadb_vendor: 'mariadb' }
|
||||
|
||||
License
|
||||
-------
|
||||
|
|
|
@ -16,13 +16,13 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
cases = [
|
||||
# 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: nil, vars: {mysql_origin: 'default', mysql_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: nil, vars: {mysql_origin: 'upstream', mysql_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: nil, vars: {mysql_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: dk_deb_stretch, vars: {mariadb_origin: 'default', mariadb_vendor: 'mariadb' }, groups: ['master'] },
|
||||
{ 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: {mariadb_origin: 'upstream', mariadb_vendor: 'mariadb' }, groups: ['master'] },
|
||||
{ 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: {mariadb_origin: 'upstream' }, groups: ['mariadbgalera', '1'] },
|
||||
{ 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: {mariadb_origin: 'upstream' }, groups: ['mariadbgalera', '3'] },
|
||||
]
|
||||
|
||||
cases.each_with_index do |opts,index|
|
||||
|
|
|
@ -3,145 +3,145 @@
|
|||
# -------------------------------------
|
||||
# Setup
|
||||
# -------------------------------------
|
||||
mysql_origin: 'default'
|
||||
mysql_vendor: 'mariadb'
|
||||
mysql_root_password: 'change_me_NOW'
|
||||
mysql_notify_restart: true
|
||||
mysql_upstream_apt_src: false
|
||||
mysql_manage_logrotate: true
|
||||
mariadb_origin: 'default'
|
||||
mariadb_vendor: 'mariadb'
|
||||
mariadb_root_password: 'change_me_NOW'
|
||||
mariadb_notify_restart: true
|
||||
mariadb_upstream_apt_src: false
|
||||
mariadb_manage_logrotate: true
|
||||
|
||||
# -------------------------------------
|
||||
# Configuration
|
||||
# -------------------------------------
|
||||
|
||||
# MySQL configuration template
|
||||
mysql_config_template: 'etc/mysql/my.cnf.j2'
|
||||
mariadb_config_template: 'etc/mysql/my.cnf.j2'
|
||||
|
||||
# MySQL connection settings.
|
||||
mysql_port: "3306"
|
||||
mysql_bind_address: '127.0.0.1'
|
||||
mysql_datadir: '/var/lib/mysql'
|
||||
mysql_pid_file: '/var/run/mysqld/mysqld.pid'
|
||||
mysql_socket: '/var/run/mysqld/mysqld.sock'
|
||||
mariadb_port: "3306"
|
||||
mariadb_bind_address: '127.0.0.1'
|
||||
mariadb_datadir: '/var/lib/mysql'
|
||||
mariadb_pid_file: '/var/run/mysqld/mysqld.pid'
|
||||
mariadb_socket: '/var/run/mysqld/mysqld.sock'
|
||||
|
||||
# Slow query log settings.
|
||||
mysql_slow_query_log_enabled: false
|
||||
mysql_slow_query_log_file: '/var/log/mysql/mysql_slow.log'
|
||||
mysql_slow_query_time: 2
|
||||
mariadb_slow_query_log_enabled: false
|
||||
mariadb_slow_query_log_file: '/var/log/mysql/mysql_slow.log'
|
||||
mariadb_slow_query_time: 2
|
||||
|
||||
# Memory settings (default values optimized ~512MB RAM).
|
||||
mysql_key_buffer_size: '256M'
|
||||
mysql_max_allowed_packet: '64M'
|
||||
mysql_table_open_cache: '256'
|
||||
mysql_sort_buffer_size: '1M'
|
||||
mysql_read_buffer_size: '1M'
|
||||
mysql_read_rnd_buffer_size: '4M'
|
||||
mysql_myisam_sort_buffer_size: '64M'
|
||||
mysql_thread_cache_size: '8'
|
||||
mysql_query_cache_size: '16M'
|
||||
mariadb_key_buffer_size: '256M'
|
||||
mariadb_max_allowed_packet: '64M'
|
||||
mariadb_table_open_cache: '256'
|
||||
mariadb_sort_buffer_size: '1M'
|
||||
mariadb_read_buffer_size: '1M'
|
||||
mariadb_read_rnd_buffer_size: '4M'
|
||||
mariadb_myisam_sort_buffer_size: '64M'
|
||||
mariadb_thread_cache_size: '8'
|
||||
mariadb_query_cache_size: '16M'
|
||||
|
||||
# Other settings.
|
||||
mysql_wait_timeout: 28800
|
||||
mariadb_wait_timeout: 28800
|
||||
|
||||
# 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.
|
||||
mysql_innodb_file_per_table: '1'
|
||||
mysql_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
|
||||
mysql_innodb_log_buffer_size: '8M'
|
||||
mysql_innodb_flush_log_at_trx_commit: '1'
|
||||
mysql_innodb_lock_wait_timeout: 50
|
||||
mariadb_innodb_file_per_table: '1'
|
||||
mariadb_innodb_buffer_pool_size: "{{ (ansible_memtotal_mb * 0.2) | round | int }}M"
|
||||
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
|
||||
mariadb_innodb_log_buffer_size: '8M'
|
||||
mariadb_innodb_flush_log_at_trx_commit: '1'
|
||||
mariadb_innodb_lock_wait_timeout: 50
|
||||
|
||||
# mysqldump settings.
|
||||
mysql_mysqldump_max_allowed_packet: '64M'
|
||||
mariadb_mysqldump_max_allowed_packet: '64M'
|
||||
|
||||
# Logging settings.
|
||||
mysql_log_error: '/var/log/mysql/mysql_error.log'
|
||||
mysql_syslog_tag: 'mysql'
|
||||
mariadb_log_error: '/var/log/mysql/mysql_error.log'
|
||||
mariadb_syslog_tag: 'mysql'
|
||||
|
||||
# -------------------------------------
|
||||
# Extra configuration
|
||||
# -------------------------------------
|
||||
#
|
||||
mysql_extra_configuration: {}
|
||||
mariadb_extra_configuration: {}
|
||||
|
||||
# Example:
|
||||
#mysql_extra_configuration:
|
||||
#mariadb_extra_configuration:
|
||||
# 'innodb_awsome_feature': 1
|
||||
|
||||
|
||||
# -------------------------------------
|
||||
# Replication
|
||||
# -------------------------------------
|
||||
mysql_replication_master: false
|
||||
mysql_replication_slave: false
|
||||
mariadb_replication_master: false
|
||||
mariadb_replication_slave: false
|
||||
# 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'
|
||||
mysql_replication_password: 'change_me_NOW'
|
||||
mysql_replication_host: '192.168.0.1'
|
||||
mysql_replication_port: '3306'
|
||||
mariadb_replication_user: 'repl'
|
||||
mariadb_replication_password: 'change_me_NOW'
|
||||
mariadb_replication_host: '192.168.0.1'
|
||||
mariadb_replication_port: '3306'
|
||||
|
||||
mysql_backup_dir: '/var/backups/tmp-mysql'
|
||||
mariadb_backup_dir: '/var/backups/tmp-mysql'
|
||||
|
||||
# Master
|
||||
mysql_max_binlog_size: "100M"
|
||||
mysql_expire_logs_days: "10"
|
||||
mariadb_max_binlog_size: "100M"
|
||||
mariadb_expire_logs_days: "10"
|
||||
|
||||
#
|
||||
# Slave
|
||||
#
|
||||
mysql_slave_readonly: true
|
||||
mariadb_slave_readonly: true
|
||||
# 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
|
||||
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)
|
||||
mysql_slave_import_flush_dump: true
|
||||
mariadb_slave_import_flush_dump: true
|
||||
# Slave uses mysql database from master?
|
||||
mysql_slave_replicate_mysqldb: true
|
||||
mariadb_slave_replicate_mysqldb: true
|
||||
# Don't replicate these DBs/tables
|
||||
mysql_slave_ignore_db: []
|
||||
mysql_slave_ignore_table: []
|
||||
mariadb_slave_ignore_db: []
|
||||
mariadb_slave_ignore_table: []
|
||||
# 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
|
||||
mysql_master_log_file: null
|
||||
mysql_master_log_pos: null
|
||||
mariadb_master_log_file: null
|
||||
mariadb_master_log_pos: null
|
||||
# If true, reconfigure slave
|
||||
mysql_slave_force_setup: false
|
||||
mysql_gtid_domain_id: 1
|
||||
mariadb_slave_force_setup: false
|
||||
mariadb_gtid_domain_id: 1
|
||||
|
||||
# -------------------------------------
|
||||
# Database / Users
|
||||
# -------------------------------------
|
||||
mysql_databases: []
|
||||
mysql_users: []
|
||||
mariadb_databases: []
|
||||
mariadb_users: []
|
||||
|
||||
# -------------------------------------
|
||||
# MariaDB
|
||||
# -------------------------------------
|
||||
mysql_mariadb_version: '10.1'
|
||||
mysql_mariadb_mirror_domain: "ftp.igh.cnrs.fr"
|
||||
mariadb_version: '10.1'
|
||||
mariadb_mirror_domain: "ftp.igh.cnrs.fr"
|
||||
# See: https://downloads.mariadb.org/mariadb/repositories
|
||||
mysql_mariadb_repository: "http://{{ mysql_mariadb_mirror_domain }}/pub/mariadb/repo/{{ mysql_mariadb_version }}/debian"
|
||||
mysql_mariadb_key_server: "keyserver.ubuntu.com"
|
||||
mysql_mariadb_key_ids: ['0xcbcb082a1bb943db', '0xf1656f24c74cd1d8']
|
||||
mariadb_repository: "http://{{ mariadb_mirror_domain }}/pub/mariadb/repo/{{ mariadb_version }}/debian"
|
||||
mariadb_key_server: "keyserver.ubuntu.com"
|
||||
mariadb_key_ids: ['0xcbcb082a1bb943db', '0xf1656f24c74cd1d8']
|
||||
|
||||
# -------------------------------------
|
||||
# Galera
|
||||
# -------------------------------------
|
||||
mysql_galera_resetup: false
|
||||
mysql_galera_members: []
|
||||
mysql_galera_primary_node: 'change_me' # See: https://github.com/ansible/ansible/issues/17453
|
||||
mariadb_galera_resetup: false
|
||||
mariadb_galera_members: []
|
||||
mariadb_galera_primary_node: 'change_me' # See: https://github.com/ansible/ansible/issues/17453
|
||||
|
||||
# -------------------------------------
|
||||
# Percona
|
||||
# -------------------------------------
|
||||
mysql_percona_repository: 'http://repo.percona.com/apt'
|
||||
mysql_use_percona_apt: false
|
||||
mysql_install_xtrabackup_package: false
|
||||
mysql_xtrabackup_package: "{{ mysql_default_xtrabackup_package }}"
|
||||
mariadb_percona_repository: 'http://repo.percona.com/apt'
|
||||
mariadb_use_percona_apt: false
|
||||
mariadb_install_xtrabackup_package: false
|
||||
mariadb_xtrabackup_package: "{{ mariadb_default_xtrabackup_package }}"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
|
||||
- name: restart mysql
|
||||
action: service name=mysql state=restarted enabled=yes
|
||||
when: mysql_notify_restart
|
||||
- name: restart mariadb
|
||||
service:
|
||||
name: mysql
|
||||
state: restarted
|
||||
when: mariadb_notify_restart
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
- set_fact:
|
||||
booboo: "{{ mysql_datadir }}/.ansible_galera_boostrap"
|
||||
booboo: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
|
||||
|
||||
- name: STAT | Bootstrap mark
|
||||
stat: path={{ booboo }}
|
||||
|
@ -9,7 +9,7 @@
|
|||
- block:
|
||||
- name: SET_FACT | We must NOT restart after bootstrap!
|
||||
set_fact:
|
||||
mysql_notify_restart: false
|
||||
mariadb_notify_restart: false
|
||||
|
||||
- name: SERVICE | Stop MariaDB
|
||||
service: name=mysql state=stopped
|
||||
|
@ -26,7 +26,7 @@
|
|||
register: bootstrap_run
|
||||
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
|
||||
command: "touch {{ booboo }}"
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
- name: INCLUDE | Bootstrap first node
|
||||
include: 'bootstrap.yml'
|
||||
when: inventory_hostname == mysql_galera_primary_node
|
||||
when: inventory_hostname == mariadb_galera_primary_node
|
||||
|
||||
- name: INCLUDE | Configure other nodes
|
||||
include: 'nodes.yml'
|
||||
when: inventory_hostname != mysql_galera_primary_node
|
||||
when: inventory_hostname != mariadb_galera_primary_node
|
||||
|
||||
- name: SERVICE | Restart MariaDB if needed
|
||||
service: name=mysql state=restarted
|
||||
when: >
|
||||
((galeraconfig or (p is defined and p.changed)) and
|
||||
(bootstrap_run is not defined)) or
|
||||
((inventory_hostname != mysql_galera_primary_node) and
|
||||
(mysql_galera_resetup))
|
||||
((inventory_hostname != mariadb_galera_primary_node) and
|
||||
(mariadb_galera_resetup))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
- name: COMMAND | GET debian.cnf from primary node
|
||||
command: cat /etc/mysql/debian.cnf
|
||||
register: debiancnf
|
||||
delegate_to: '{{ mysql_galera_primary_node }}'
|
||||
delegate_to: '{{ mariadb_galera_primary_node }}'
|
||||
changed_when: false
|
||||
|
||||
- name: COMMAND | Get current debian.cnf
|
||||
|
|
|
@ -2,23 +2,23 @@
|
|||
|
||||
- name: INCLUDE | Use Percona repository
|
||||
include: 'percona/apt.yml'
|
||||
when: mysql_use_percona_apt
|
||||
when: mariadb_use_percona_apt
|
||||
|
||||
- name: INCLUDE | Install MariaDB from Debian repo
|
||||
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
|
||||
include: 'mariadb/upstream.yml'
|
||||
when: mysql_origin == 'upstream'
|
||||
when: mariadb_origin == 'upstream'
|
||||
|
||||
- name: APT | Install few MySQL related tools
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
install_recommends: no
|
||||
with_items: "{{ mysql_tools }}"
|
||||
with_items: "{{ mariadb_tools }}"
|
||||
|
||||
- name: APT | Install percona-xtrabackup if needed
|
||||
apt:
|
||||
pkg: "{{ mysql_xtrabackup_package }}"
|
||||
when: mysql_install_xtrabackup_package
|
||||
pkg: "{{ mariadb_xtrabackup_package }}"
|
||||
when: mariadb_install_xtrabackup_package
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
changed_when: false
|
||||
|
||||
- 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 }}'
|
||||
when: not mysql_exists.stat.exists
|
||||
debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password' vtype='password' value='{{ mariadb_root_password }}'
|
||||
when: not mariadb_exists.stat.exists
|
||||
|
||||
- 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 }}'
|
||||
when: not mysql_exists.stat.exists
|
||||
debconf: name='mariadb-server-{{ apt_mariadb_version.stdout }}' question='mysql-server/root_password_again' vtype='password' value='{{ mariadb_root_password }}'
|
||||
when: not mariadb_exists.stat.exists
|
||||
|
||||
- name: APT | Install MariaDB server
|
||||
apt: pkg=mariadb-server state=present
|
||||
|
||||
- name: APT | Install Galera
|
||||
apt: pkg=galera-3 state=present
|
||||
when: mysql_vendor == 'mariadb_galera'
|
||||
when: mariadb_vendor == 'mariadb_galera'
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
|
||||
- name: APT_KEY | Install MariaDB key
|
||||
apt_key: keyserver="{{ mysql_mariadb_key_server }}" id={{ item }} state=present
|
||||
with_items: "{{ mysql_mariadb_key_ids }}"
|
||||
apt_key: keyserver="{{ mariadb_mariadb_key_server }}" id={{ item }} state=present
|
||||
with_items: "{{ mariadb_mariadb_key_ids }}"
|
||||
|
||||
- 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
|
||||
|
||||
- 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
|
||||
apt_repository: repo='deb-src {{ mysql_mariadb_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
when: mysql_upstream_apt_src
|
||||
apt_repository: repo='deb-src {{ mariadb_mariadb_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
when: mariadb_upstream_apt_src
|
||||
|
||||
- name: INCLUDE | Normal Install
|
||||
include: default.yml
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
template: src=etc/apt/preferences.d/95-percona.j2 dest=/etc/apt/preferences.d/95-percona
|
||||
|
||||
- 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
|
||||
apt_repository: repo='deb-src {{ mysql_percona_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
when: mysql_upstream_apt_src
|
||||
apt_repository: repo='deb-src {{ mariadb_percona_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
when: mariadb_upstream_apt_src
|
||||
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
|
||||
- name: STAT | Check if mysql exists
|
||||
stat: path=/etc/init.d/mysql
|
||||
register: mysql_exists
|
||||
stat:
|
||||
path: /usr/bin/mariadb
|
||||
register: mariadb_exists
|
||||
changed_when: false
|
||||
|
||||
- name: INCLUDE | Install
|
||||
include: install/main.yml
|
||||
|
||||
- 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
|
||||
|
||||
- name: TEMPLATE | Deploy extra configuration
|
||||
|
@ -23,18 +24,18 @@
|
|||
service: name=mysql state=restarted
|
||||
when: >
|
||||
(config.changed or extraconfig.changed) and
|
||||
not mysql_galera_resetup
|
||||
not mariadb_galera_resetup
|
||||
|
||||
- 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 | Galera
|
||||
include: galera/main.yml
|
||||
when: mysql_vendor == 'mariadb_galera'
|
||||
when: mariadb_vendor == 'mariadb_galera'
|
||||
|
||||
- name: INCLUDE | Replication
|
||||
include: replication/main.yml
|
||||
when: mysql_replication_master or mysql_replication_slave
|
||||
when: mariadb_replication_master or mariadb_replication_slave
|
||||
|
||||
- name: INCLUDE | Secure install
|
||||
include: 'secure.yml'
|
||||
|
@ -44,7 +45,7 @@
|
|||
|
||||
- name: MYSQL_DB | Create databases
|
||||
mysql_db: name={{ item }} state=present
|
||||
with_items: "{{ mysql_databases }}"
|
||||
with_items: "{{ mariadb_databases }}"
|
||||
|
||||
- name: MYSQL_USER | Manages users...
|
||||
mysql_user: >
|
||||
|
@ -53,10 +54,10 @@
|
|||
priv="{{ item.priv }}"
|
||||
host="{{ item.host | default('localhost') }}"
|
||||
state=present
|
||||
with_items: "{{ mysql_users }}"
|
||||
with_items: "{{ mariadb_users }}"
|
||||
|
||||
- name: TEMPLATE | Deploy logrotate configuration
|
||||
template:
|
||||
src: "etc/logrotate.d/mysql-server.j2"
|
||||
dest: "/etc/logrotate.d/mysql-server"
|
||||
when: mysql_manage_logrotate
|
||||
when: mariadb_manage_logrotate
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
- name: INCLUDE | Replication Master
|
||||
include: master.yml
|
||||
when: mysql_replication_master
|
||||
when: mariadb_replication_master
|
||||
|
||||
- name: INCLUDE | Replication slave
|
||||
include: slave.yml
|
||||
when: mysql_replication_slave
|
||||
when: mariadb_replication_slave
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
template: >
|
||||
src=etc/mysql/conf.d/50-master.cnf.j2
|
||||
dest=/etc/mysql/conf.d/50-master.cnf
|
||||
notify: restart mysql
|
||||
notify: restart mariadb
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
- name: MYSQL_VARIABLES | Set read only
|
||||
mysql_variables: variable=read_only value=ON
|
||||
when: mysql_slave_readonly
|
||||
when: mariadb_slave_readonly
|
||||
|
||||
- name: TEMPLATE | Deploy slave configuration
|
||||
template: >
|
||||
src=etc/mysql/conf.d/51-slave.cnf.j2
|
||||
dest=/etc/mysql/conf.d/51-slave.cnf
|
||||
notify: restart mysql
|
||||
notify: restart mariadb
|
||||
|
||||
- name: MYSQL_REPLICATION | Get slave status
|
||||
mysql_replication: mode=getslave
|
||||
|
@ -17,19 +17,19 @@
|
|||
|
||||
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
|
||||
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
|
||||
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
|
||||
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
|
||||
include: slave/debiancnf.yml
|
||||
when: mysql_slave_replicate_mysqldb
|
||||
when: mariadb_slave_replicate_mysqldb
|
||||
|
||||
- name: MYSQL_REPLICATION | Get slave status
|
||||
mysql_replication: mode=getslave
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
- name: FETCH | Get /etc/mysql/debian.cnf on master
|
||||
fetch: >
|
||||
src=/etc/mysql/debian.cnf
|
||||
dest=/tmp/{{ mysql_slave_import_from }}/debian.cnf
|
||||
dest=/tmp/{{ mariadb_slave_import_from }}/debian.cnf
|
||||
flat=yes
|
||||
changed_when: false
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
|
||||
- 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
|
||||
|
||||
- name: COPY | Fetched file to /etc/mysql/debian.cnf
|
||||
copy: >
|
||||
src=/tmp/{{ mysql_slave_import_from }}/debian.cnf
|
||||
src=/tmp/{{ mariadb_slave_import_from }}/debian.cnf
|
||||
dest=/etc/mysql/debian.cnf
|
||||
owner=root group=root mode=0600
|
||||
notify: restart mysql
|
||||
notify: restart mariadb
|
||||
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
# 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
|
||||
wait_for: host={{ mysql_slave_import_from }} port=22
|
||||
wait_for: host={{ mariadb_slave_import_from }} port=22
|
||||
|
||||
- name: COMMAND | Prepare backup another server
|
||||
command: innobackupex --no-timestamp {{ mysql_backup_dir }} creates={{ mysql_backup_dir }}
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
command: innobackupex --no-timestamp {{ mariadb_backup_dir }} creates={{ mariadb_backup_dir }}
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
register: backup
|
||||
|
||||
- name: SHELL | Dump
|
||||
shell: innobackupex --apply-log {{ mysql_backup_dir }}
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
shell: innobackupex --apply-log {{ mariadb_backup_dir }}
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
when: backup.changed
|
||||
|
||||
- name: FILE | Remove mysql db from backup
|
||||
file: path={{ mysql_backup_dir }}/mysql state=absent
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
when: backup.changed and not mysql_slave_replicate_mysqldb
|
||||
file: path={{ mariadb_backup_dir }}/mysql state=absent
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
when: backup.changed and not mariadb_slave_replicate_mysqldb
|
||||
|
||||
- name: MYSQL_VARIABLES | Get datadir
|
||||
mysql_variables: variable=datadir
|
||||
|
@ -25,20 +25,20 @@
|
|||
|
||||
- name: SET_FACT | related to mysql datadir
|
||||
set_fact:
|
||||
mysql_mysql_datadir: "{{ datadir.msg }}"
|
||||
mysql_binlog_info: "{{ datadir.msg }}/xtrabackup_binlog_info"
|
||||
mariadb_mariadb_datadir: "{{ datadir.msg }}"
|
||||
mariadb_binlog_info: "{{ datadir.msg }}/xtrabackup_binlog_info"
|
||||
|
||||
- name: SERVICE | Stop MySQL before importing data
|
||||
service: name=mysql state=stopped
|
||||
|
||||
# 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)
|
||||
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 }}/"
|
||||
- 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' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_mariadb_datadir }}/"
|
||||
become: no
|
||||
|
||||
- name: FILE | Re-apply owner
|
||||
file: >
|
||||
path={{ mysql_mysql_datadir }}
|
||||
path={{ mariadb_mariadb_datadir }}
|
||||
state=directory
|
||||
owner=mysql
|
||||
group=mysql
|
||||
|
@ -48,25 +48,25 @@
|
|||
service: name=mysql state=started
|
||||
|
||||
- name: SHELL | Get master_log_file
|
||||
command: awk '{ print $1 }' {{ mysql_binlog_info }}
|
||||
command: awk '{ print $1 }' {{ mariadb_binlog_info }}
|
||||
register: master_log_file
|
||||
|
||||
- name: SHELL | Get master_log_pos
|
||||
command: awk '{ print $2 }' {{ mysql_binlog_info }}
|
||||
command: awk '{ print $2 }' {{ mariadb_binlog_info }}
|
||||
register: master_log_pos
|
||||
|
||||
- name: SHELL | Get master GTID
|
||||
command: awk '{ print $3 }' {{ mysql_binlog_info }}
|
||||
command: awk '{ print $3 }' {{ mariadb_binlog_info }}
|
||||
register: master_gtid
|
||||
|
||||
- name: SET_FACT | master_log_file
|
||||
set_fact:
|
||||
mysql_master_log_file: "{{ master_log_file.stdout }}"
|
||||
mysql_master_log_pos: "{{ master_log_pos.stdout }}"
|
||||
mysql_master_gtid: "{{ master_gtid.stdout }}"
|
||||
mariadb_master_log_file: "{{ master_log_file.stdout }}"
|
||||
mariadb_master_log_pos: "{{ master_log_pos.stdout }}"
|
||||
mariadb_master_gtid: "{{ master_gtid.stdout }}"
|
||||
|
||||
- name: FILE | Delete dump
|
||||
file: path={{ mysql_backup_dir }} state=absent
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
when: mysql_slave_import_flush_dump
|
||||
file: path={{ mariadb_backup_dir }} state=absent
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
when: mariadb_slave_import_flush_dump
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
- name: MYSQL_REPLICATION | Configure master host
|
||||
mysql_replication: >
|
||||
mode=changemaster
|
||||
master_host={{ mysql_replication_host }}
|
||||
master_port={{ mysql_replication_port }}
|
||||
master_user={{ mysql_replication_user }}
|
||||
master_password={{ mysql_replication_password }}
|
||||
master_host={{ mariadb_replication_host }}
|
||||
master_port={{ mariadb_replication_port }}
|
||||
master_user={{ mariadb_replication_user }}
|
||||
master_password={{ mariadb_replication_password }}
|
||||
|
||||
- name: MYSQL_REPLICATION | Change master
|
||||
mysql_replication: >
|
||||
mode=changemaster
|
||||
master_log_file={{ mysql_master_log_file }}
|
||||
master_log_pos={{ mysql_master_log_pos }}
|
||||
when: mysql_master_log_file is defined and mysql_master_log_pos is defined
|
||||
master_log_file={{ mariadb_master_log_file }}
|
||||
master_log_pos={{ mariadb_master_log_pos }}
|
||||
when: mariadb_master_log_file is defined and mariadb_master_log_pos is defined
|
||||
|
||||
- name: MYSQL_REPLICATION | Start slave
|
||||
mysql_replication: mode=startslave
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
- name: AUTHORIZED_KEY | Auth slave to backup host
|
||||
authorized_key:
|
||||
user: "{{ mysql_backup_user }}"
|
||||
user: "{{ mariadb_backup_user }}"
|
||||
state: present
|
||||
key: "{{ pub_key.stdout }}"
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
become: yes
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
|
||||
- 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:
|
||||
- "{{ ansible_hostname }}"
|
||||
- 127.0.0.1
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
Explanation: Prevent Debian upgrades on mariadb packages
|
||||
Package: *
|
||||
Pin: origin {{ mysql_mariadb_mirror_domain }}
|
||||
Pin: origin {{ mariadb_mariadb_mirror_domain }}
|
||||
Pin-Priority: 1000
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# flush-logs'd only once.
|
||||
# Else the binary logs would automatically increase by n times every day.
|
||||
# - 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
|
||||
rotate 7
|
||||
missingok
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
# Global
|
||||
wsrep_on=ON
|
||||
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
|
||||
wsrep_sst_method=rsync
|
||||
# TODO: wsrep_cluster_name="my_wsrep_cluster"
|
||||
|
||||
# Node Configuration
|
||||
wsrep_node_address="{{ mysql_wsrep_node_address | default(ansible_default_ipv4.address) }}"
|
||||
wsrep_node_name="{{ mysql_wsrep_node_name | default(ansible_fqdn) }}"
|
||||
wsrep_node_address="{{ mariadb_wsrep_node_address | default(ansible_default_ipv4.address) }}"
|
||||
wsrep_node_name="{{ mariadb_wsrep_node_name | default(ansible_fqdn) }}"
|
||||
|
||||
|
||||
# --------------------
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# -------------------------------------------
|
||||
|
||||
[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 %}
|
||||
{{ key }} = {{ value }}
|
||||
{% else %}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
# Replication master
|
||||
|
||||
[mysqld]
|
||||
server_id={{ mysql_server_id }}
|
||||
server_id={{ mariadb_server_id }}
|
||||
log_bin = mysql-bin
|
||||
log-bin-index = mysql-bin.index
|
||||
expire_logs_days = {{ mysql_expire_logs_days }}
|
||||
max_binlog_size = {{ mysql_max_binlog_size }}
|
||||
gtid_domain_id={{ mysql_gtid_domain_id }}
|
||||
expire_logs_days = {{ mariadb_expire_logs_days }}
|
||||
max_binlog_size = {{ mariadb_max_binlog_size }}
|
||||
gtid_domain_id={{ mariadb_gtid_domain_id }}
|
||||
|
||||
; vim: set ft=dosini :
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
# Replication slave
|
||||
|
||||
[mysqld]
|
||||
server_id={{ mysql_server_id }}
|
||||
{% if mysql_slave_readonly %}
|
||||
server_id={{ mariadb_server_id }}
|
||||
{% if mariadb_slave_readonly %}
|
||||
read-only
|
||||
{% endif %}
|
||||
|
||||
# --> Ignore DB/tables
|
||||
{% if not mysql_slave_replicate_mysqldb %}
|
||||
{% if not mariadb_slave_replicate_mysqldb %}
|
||||
replicate-ignore-db=mysql
|
||||
{% endif %}
|
||||
{% for db in mysql_slave_ignore_db %}
|
||||
{% for db in mariadb_slave_ignore_db %}
|
||||
replicate-ignore-db={{ db }}
|
||||
{% endfor %}
|
||||
{% for t in mysql_slave_ignore_table %}
|
||||
{% for t in mariadb_slave_ignore_table %}
|
||||
replicate-ignore-table={{ t }}
|
||||
{% endfor %}
|
||||
# <-- Ignore DB/tables
|
||||
|
|
|
@ -3,29 +3,29 @@
|
|||
#
|
||||
|
||||
[client]
|
||||
port = {{ mysql_port }}
|
||||
socket = {{ mysql_socket }}
|
||||
port = {{ mariadb_port }}
|
||||
socket = {{ mariadb_socket }}
|
||||
|
||||
[mysqld]
|
||||
port = {{ mysql_port }}
|
||||
bind-address = {{ mysql_bind_address }}
|
||||
datadir = {{ mysql_datadir }}
|
||||
socket = {{ mysql_socket }}
|
||||
port = {{ mariadb_port }}
|
||||
bind-address = {{ mariadb_bind_address }}
|
||||
datadir = {{ mariadb_datadir }}
|
||||
socket = {{ mariadb_socket }}
|
||||
|
||||
{# TODO: FIX later #}
|
||||
# Logging configuration.
|
||||
{% if mysql_log_error == 'syslog' %}
|
||||
{% if mariadb_log_error == 'syslog' %}
|
||||
syslog
|
||||
syslog-tag = {{ mysql_syslog_tag }}
|
||||
syslog-tag = {{ mariadb_syslog_tag }}
|
||||
{% else %}
|
||||
log-error = {{ mysql_log_error }}
|
||||
log-error = {{ mariadb_log_error }}
|
||||
{% endif %}
|
||||
|
||||
{% if mysql_slow_query_log_enabled %}
|
||||
{% if mariadb_slow_query_log_enabled %}
|
||||
# Slow query log configuration.
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = {{ mysql_slow_query_log_file }}
|
||||
long_query_time = {{ mysql_slow_query_time }}
|
||||
slow_query_log_file = {{ mariadb_slow_query_log_file }}
|
||||
long_query_time = {{ mariadb_slow_query_time }}
|
||||
{% endif %}
|
||||
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
|
@ -38,39 +38,39 @@ user = mysql
|
|||
;performance_schema
|
||||
|
||||
# Memory settings.
|
||||
key_buffer_size = {{ mysql_key_buffer_size }}
|
||||
max_allowed_packet = {{ mysql_max_allowed_packet }}
|
||||
table_open_cache = {{ mysql_table_open_cache }}
|
||||
sort_buffer_size = {{ mysql_sort_buffer_size }}
|
||||
read_buffer_size = {{ mysql_read_buffer_size }}
|
||||
read_rnd_buffer_size = {{ mysql_read_rnd_buffer_size }}
|
||||
myisam_sort_buffer_size = {{ mysql_myisam_sort_buffer_size }}
|
||||
thread_cache_size = {{ mysql_thread_cache_size }}
|
||||
query_cache_size = {{ mysql_query_cache_size }}
|
||||
key_buffer_size = {{ mariadb_key_buffer_size }}
|
||||
max_allowed_packet = {{ mariadb_max_allowed_packet }}
|
||||
table_open_cache = {{ mariadb_table_open_cache }}
|
||||
sort_buffer_size = {{ mariadb_sort_buffer_size }}
|
||||
read_buffer_size = {{ mariadb_read_buffer_size }}
|
||||
read_rnd_buffer_size = {{ mariadb_read_rnd_buffer_size }}
|
||||
myisam_sort_buffer_size = {{ mariadb_myisam_sort_buffer_size }}
|
||||
thread_cache_size = {{ mariadb_thread_cache_size }}
|
||||
query_cache_size = {{ mariadb_query_cache_size }}
|
||||
|
||||
# Other settings.
|
||||
wait_timeout = {{ mysql_wait_timeout }}
|
||||
wait_timeout = {{ mariadb_wait_timeout }}
|
||||
|
||||
# Try number of CPU's * 2 for thread_concurrency.
|
||||
thread_concurrency = {{ mysql_thread_concurrency }}
|
||||
thread_concurrency = {{ mariadb_thread_concurrency }}
|
||||
|
||||
# InnoDB settings.
|
||||
innodb_file_per_table = {{ mysql_innodb_file_per_table }}
|
||||
innodb_buffer_pool_size = {{ mysql_innodb_buffer_pool_size }}
|
||||
innodb_log_buffer_size = {{ mysql_innodb_log_buffer_size }}
|
||||
innodb_flush_log_at_trx_commit = {{ mysql_innodb_flush_log_at_trx_commit }}
|
||||
innodb_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }}
|
||||
innodb_file_per_table = {{ mariadb_innodb_file_per_table }}
|
||||
innodb_buffer_pool_size = {{ mariadb_innodb_buffer_pool_size }}
|
||||
innodb_log_buffer_size = {{ mariadb_innodb_log_buffer_size }}
|
||||
innodb_flush_log_at_trx_commit = {{ mariadb_innodb_flush_log_at_trx_commit }}
|
||||
innodb_lock_wait_timeout = {{ mariadb_innodb_lock_wait_timeout }}
|
||||
{# 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 #}
|
||||
{# 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]
|
||||
quick
|
||||
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }}
|
||||
max_allowed_packet = {{ mariadb_mysqldump_max_allowed_packet }}
|
||||
|
||||
[mysqld_safe]
|
||||
pid-file = {{ mysql_pid_file }}
|
||||
pid-file = {{ mariadb_pid_file }}
|
||||
|
||||
#
|
||||
# * IMPORTANT: Additional settings that can override those from this file!
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
[client]
|
||||
user=root
|
||||
password="{{ mysql_root_password }}"
|
||||
password="{{ mariadb_root_password }}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mysql_bind_address: '0.0.0.0'
|
||||
mysql_extra_configuration:
|
||||
mariadb_bind_address: '0.0.0.0'
|
||||
mariadb_extra_configuration:
|
||||
innodb_commit_concurrency: 0
|
||||
mysql_use_percona_apt: true
|
||||
mysql_install_xtrabackup_package: true
|
||||
mysql_slow_query_log_enabled: true
|
||||
mariadb_use_percona_apt: true
|
||||
mariadb_install_xtrabackup_package: true
|
||||
mariadb_slow_query_log_enabled: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mysql_vendor: 'mariadb_galera'
|
||||
mysql_galera_members:
|
||||
mariadb_vendor: 'mariadb_galera'
|
||||
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-2'
|
||||
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-3'
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
# Master durability
|
||||
mysql_sync_binlog: '1'
|
||||
mysql_innodb_flush_log_at_trx_commit: '1'
|
||||
mariadb_sync_binlog: '1'
|
||||
mariadb_innodb_flush_log_at_trx_commit: '1'
|
||||
|
||||
mysql_databases:
|
||||
mariadb_databases:
|
||||
- 'testrepl'
|
||||
- 'norepl'
|
||||
|
||||
mysql_users:
|
||||
mariadb_users:
|
||||
- name: 'replication'
|
||||
password: '1a2b3c'
|
||||
priv: '*.*:REPLICATION SLAVE'
|
||||
host: '%'
|
||||
mysql_replication_master: true
|
||||
mysql_replication_slave: false
|
||||
mysql_server_id: 1
|
||||
mariadb_replication_master: true
|
||||
mariadb_replication_slave: false
|
||||
mariadb_server_id: 1
|
||||
|
||||
# vim: set ft=yaml :
|
||||
|
|
|
@ -1 +1 @@
|
|||
mysql_vendor: 'mysql'
|
||||
mariadb_vendor: 'mysql'
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
mysql_replication_master: false
|
||||
mysql_replication_slave: true
|
||||
mysql_replication_user: 'replication'
|
||||
mysql_replication_password: '1a2b3c'
|
||||
mysql_server_id: 2
|
||||
mysql_slave_ignore_db: ['norepl']
|
||||
mariadb_replication_master: false
|
||||
mariadb_replication_slave: true
|
||||
mariadb_replication_user: 'replication'
|
||||
mariadb_replication_password: '1a2b3c'
|
||||
mariadb_server_id: 2
|
||||
mariadb_slave_ignore_db: ['norepl']
|
||||
|
||||
# vim: set ft=yaml :
|
||||
|
|
|
@ -27,18 +27,18 @@
|
|||
changed_when: false
|
||||
- set_fact:
|
||||
# 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'
|
||||
mysql_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
|
||||
mariadb_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
|
||||
roles:
|
||||
- ../../
|
||||
tasks:
|
||||
- copy: src=import2.sql dest=/tmp/import2.sql
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
register: c
|
||||
- mysql_db: name={{ item }} state=import target=/tmp/import2.sql
|
||||
with_items: ['testrepl', 'norepl']
|
||||
delegate_to: "{{ mysql_slave_import_from }}"
|
||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||
when: c.changed
|
||||
- mysql_replication: mode=getslave
|
||||
register: slave
|
||||
|
@ -47,12 +47,12 @@
|
|||
|
||||
- hosts: mariadbgalera
|
||||
vars:
|
||||
mysql_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] }}"
|
||||
mysql_mariadb_version: '10.1'
|
||||
mariadb_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
|
||||
mariadb_wsrep_node_address: "{{ ansible_all_ipv4_addresses[0] }}"
|
||||
mariadb_mariadb_version: '10.1'
|
||||
pre_tasks:
|
||||
- set_fact:
|
||||
mysql_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
|
||||
mariadb_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
|
||||
when: not is_docker
|
||||
roles:
|
||||
- ../../
|
||||
|
|
|
@ -12,10 +12,10 @@ set -ev
|
|||
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
|
||||
|
||||
# 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
|
||||
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 \
|
||||
&& (echo 'Idempotence test: pass' && exit 0) \
|
||||
|| (echo 'Idempotence test: FAIL' && cat idempot.txt && exit 1)
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
- hosts: all
|
||||
vars:
|
||||
mysql_replication_master: true
|
||||
mysql_bind_address: '{{ ansible_eth0.ipv4.address }}'
|
||||
mysql_galera_members:
|
||||
mariadb_replication_master: true
|
||||
mariadb_bind_address: '{{ ansible_eth0.ipv4.address }}'
|
||||
mariadb_galera_members:
|
||||
- '{{ ansible_eth0.ipv4.address }}'
|
||||
mysql_galera_primary_node: 'localhost'
|
||||
mariadb_galera_primary_node: 'localhost'
|
||||
roles:
|
||||
- ../../
|
||||
post_tasks:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mysql_tools:
|
||||
mariadb_tools:
|
||||
- percona-toolkit
|
||||
- python-mysqldb
|
||||
- mysqltuner
|
||||
|
||||
mysql_default_xtrabackup_package: 'percona-xtrabackup-24'
|
||||
mariadb_default_xtrabackup_package: 'percona-xtrabackup-24'
|
||||
|
|
Loading…
Reference in New Issue