Role organization:

Delete useless files
percona-xtrbackup is optional on Wheezy (unless you use percona apt)
better organization in mysql vendors
pull/6/head
Emilien Mantel 2015-08-21 11:24:37 +02:00
parent f27a78b826
commit 5d6abb0dda
10 changed files with 39 additions and 23 deletions

View File

@ -1,7 +1,7 @@
MySQL vendors for Debian Ansible role MySQL vendors for Debian Ansible role
====================================== ======================================
Install and configure MySQL or MariaDB or Percona Server. Create users and databases. Install and configure MySQL or MariaDB or Percona Server. Manage replication (master/slave). Create users and databases.
Requirements Requirements
------------ ------------
@ -13,6 +13,7 @@ Role Variables
- `mysql_origin`: origin of the package ("default" or "upstream") - `mysql_origin`: origin of the package ("default" or "upstream")
- `mysql_vendor`: "mysql", "mariadb" or "percona" - `mysql_vendor`: "mysql", "mariadb" or "percona"
- `mysql_use_percona_repository`: use percona APT repository (automatic setted to true if you use "percona" as `mysql_vendor`). You need to set "true" on Wheezy if you want to install percona-xtrabackup.
### Configuration ### Configuration

View File

@ -6,6 +6,7 @@
mysql_origin: 'upstream' mysql_origin: 'upstream'
mysql_vendor: 'mariadb' mysql_vendor: 'mariadb'
mysql_root_password: 'change_me_NOW' mysql_root_password: 'change_me_NOW'
mysql_use_percona_repository: false
# ------------------------------------- # -------------------------------------
# Configuration # Configuration

View File

@ -1,7 +1,7 @@
--- ---
- name: FAIL | If config asked is impossible - name: FAIL | If config asked is impossible
fail: msg="config asked is impossible origin -> {{ mysql_origin }} vendor -> {{ mysql_vendor }}" fail: msg="config asked is impossible"
when: > when: >
not ( not (
(mysql_origin == 'default' and mysql_vendor == 'mysql') or (mysql_origin == 'default' and mysql_vendor == 'mysql') or
@ -10,33 +10,24 @@
(mysql_origin == 'upstream' and mysql_vendor == 'percona') (mysql_origin == 'upstream' and mysql_vendor == 'percona')
) )
- name: APT_KEY | Install Percona key - name: APT | Install Percona Xtrabackup
apt_key: keyserver="keyserver.ubuntu.com" id="1C4CBDCDCD2EFD2A" state=present include: percona/apt.yml
#apt_key: keyserver="keys.gnupg.net" id="1C4CBDCDCD2EFD2A" state=present when: mysql_use_percona_repository
#- name: TEMPLATE | Deploy APT pinning (prevent upgrades from Debian)
# 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 {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
- name: APT_RESPOSITORY | Add Percona (src) repository
apt_repository: repo='deb-src {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
- name: INCLUDE | Install MySQL from default repo - name: INCLUDE | Install MySQL from default repo
include: 'default_mysql.yml' include: 'mysql/default.yml'
when: mysql_origin == 'default' and mysql_vendor == 'mysql' when: mysql_origin == 'default' and mysql_vendor == 'mysql'
- name: INCLUDE | Install MariaDB from Debian repo - name: INCLUDE | Install MariaDB from Debian repo
include: 'default_mariadb.yml' include: 'mariadb/default.yml'
when: mysql_origin == 'default' and mysql_vendor == 'mariadb' and ansible_distribution_major_version > 7 when: mysql_origin == 'default' and mysql_vendor == 'mariadb' and ansible_distribution_major_version > 7
- name: INCLUDE | Install MariaDB from MariaDB repo - name: INCLUDE | Install MariaDB from MariaDB repo
include: 'upstream_mariadb.yml' include: 'mariadb/upstream.yml'
when: mysql_origin == 'upstream' and mysql_vendor == 'mariadb' when: mysql_origin == 'upstream' and mysql_vendor == 'mariadb'
- name: INCLUDE | Install Percona Server from Percona repo - name: INCLUDE | Install Percona Server from Percona repo
include: 'upstream_percona.yml' include: 'percona/upstream.yml'
when: mysql_origin == 'upstream' and mysql_vendor == 'percona' when: mysql_origin == 'upstream' and mysql_vendor == 'percona'
- name: APT | Install few MySQL related tools - name: APT | Install few MySQL related tools
@ -45,6 +36,9 @@
- mytop - mytop
- percona-toolkit - percona-toolkit
- python-mysqldb - python-mysqldb
- percona-xtrabackup
- mysqltuner - mysqltuner
- name: APT | Install Percona Xtrabackup
apt: pkg=percona-xtrabackup state=present
when: ansible_distribution_major_version > 7 or mysql_use_percona_repository

View File

@ -10,5 +10,5 @@
apt_repository: repo='deb-src {{ mariadb_repository }} {{ ansible_distribution_release }} main' state=present apt_repository: repo='deb-src {{ mariadb_repository }} {{ ansible_distribution_release }} main' state=present
- name: INCLUDE | Normal Install - name: INCLUDE | Normal Install
include: default_mariadb.yml include: default.yml

View File

@ -0,0 +1,14 @@
---
- name: APT_KEY | Install Percona key
apt_key: keyserver="keyserver.ubuntu.com" id="1C4CBDCDCD2EFD2A" state=present
- name: TEMPLATE | Deploy APT pinning (prevent upgrades from Debian)
template: src=../../../templates/etc/apt/preferences.d/95-percona.j2 dest=/etc/apt/preferences.d/95-percona
- name: APT_REPOSITORY | Add Percona repository
apt_repository: repo='deb {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
- name: APT_RESPOSITORY | Add Percona (src) repository
apt_repository: repo='deb-src {{ percona_repository }} {{ ansible_distribution_release }} main' state=present

View File

@ -1,5 +1,13 @@
--- ---
# We prevent double include
- name: INCLUDE | Add percona APT repository
include: apt.yml
when: not mysql_use_percona_repository
- name: SET_FACT | We use percona repository
set_fact: mysql_use_percona_repository=true
- name: DEBCONF | Prepare MySQL silent installation (root password) - name: DEBCONF | Prepare MySQL silent installation (root password)
debconf: name='percona-server-server-{{ percona_version }}' question='percona-server-server/root_password' vtype='password' value='{{ mysql_root_password }}' debconf: name='percona-server-server-{{ percona_version }}' question='percona-server-server/root_password' vtype='password' value='{{ mysql_root_password }}'
when: not mysql_exists.stat.exists when: not mysql_exists.stat.exists

View File

@ -1,8 +1,5 @@
--- ---
- name: INCLUDE_VARS | Related to Debian version
include_vars: "{{ ansible_distribution_release }}.yml"
- name: STAT | Check if mysql exists - name: STAT | Check if mysql exists
stat: path=/etc/init.d/mysql stat: path=/etc/init.d/mysql
register: mysql_exists register: mysql_exists

View File

@ -0,0 +1 @@
mysql_use_percona_repository: true