MySQL and Percona works

pull/6/head
Emilien Mantel 2015-07-13 12:32:49 +02:00
parent 7b2439e590
commit 1da1c01446
7 changed files with 52 additions and 34 deletions

View File

@ -3,8 +3,8 @@
# -------------------------------------
# Setup
# -------------------------------------
mysql_origin: 'default'
mysql_vendor: 'mysql'
mysql_origin: 'mariadb'
mysql_vendor: 'mariadb'
mysql_root_password: 'change_me_NOW'
# -------------------------------------
@ -29,7 +29,7 @@ mysql_users: []
# -------------------------------------
mariadb_version: '10.0' # (5.5, 10.0)
# See: http://mariadb.org/mariadb/repositories/
mariadb_repository: 'http://ftp.igh.cnrs.fr/pub/mariadb/repo/{{ mariadb_version }}/debian'
mariadb_repository: "http://ftp.igh.cnrs.fr/pub/mariadb/repo/{{ mariadb_version }}/debian"
# -------------------------------------
# Percona

View File

@ -1,12 +1,25 @@
---
- name: INCLUDE | Install MySQL from default repo
- name: FAIL | If config asked is impossible
fail: msg=config asked is impossible
when: >
not (
(mysql_origin == 'default' and mysql_vendor == 'mysql') or
(mysql_origin == 'default' and mysql_vendor == 'mariadb' and ansible_distribution_major_version > 7) or
(mysql_origin == 'mariadb' and mysql_vendor == 'mariadb') or
(mysql_origin == 'percona' and mysql_vendor == 'percona')
)
- name: APT | Update cache
apt: update_cache=yes cache_valid_time=3600
- name: INCLUDE | Install MySQL from default repo
include: 'install_default_mysql.yml'
when: mysql_origin == 'default' and mysql_vendor == 'mysql'
- name: INCLUDE | Install MariaDB from Debian repo
include: 'install_default_mariadb.yml'
when: mysql_origin == 'default' and mysql_vendor == 'mariadb'
when: mysql_origin == 'default' and mysql_vendor == 'mariadb' and ansible_distribution_major_version > 7
- name: INCLUDE | Install MariaDB from MariaDB repo
include: 'install_mariadb_mariadb.yml'
@ -21,7 +34,5 @@
with_items:
- mytop
- percona-toolkit
- python-configparser
- python-mysqldb

View File

@ -0,0 +1,22 @@
---
- name: SHELL | Get MariaDB target version
shell: LANG=C apt-cache depends mariadb-server | awk -F '-' '/Depends/ { print $NF }'
register: apt_mariadb_version
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
- name: SHELL | 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
- name: SHELL | Prepare MariaDB silent installation (root password again) // BUGGY?
debconf: name='mysql-server-' question='mysql-server/root_password_again' vtype='password' value='{{ mysql_root_password }}'
when: not mysql_exists.stat.exists
- name: APT | Install MariaDB server
apt: pkg=mariadb-server state=latest

View File

@ -2,18 +2,17 @@
- name: SHELL | Get MySQL target version
shell: LANG=C apt-cache depends mysql-server | awk -F '-' '/Depends/ { print $NF }'
register: mysql_version
when: not mysql_exists.stat.exists
register: apt_mysql_version
changed_when: false
- name: SHELL | Prepare MySQL silent installation (root password)
shell: echo 'mysql-server-{{ mysql_version.stdout }} mysql-server/root_password password {{ mysql_root_password }}' | debconf-set-selections
- name: DEBCONF | Prepare MySQL silent installation (root password)
debconf: name='mysql-server-{{ apt_mysql_version.stdout }}' question='mysql-server/root_password' vtype='password' value='{{ mysql_root_password }}'
when: not mysql_exists.stat.exists
- name: SHELL | Prepare MySQL silent installation (root password again)
shell: echo 'mysql-server-{{ mysql_version.stdout }} mysql-server/root_password_again password {{ mysql_root_password }}' | debconf-set-selections
debconf: name='mysql-server-{{ apt_mysql_version.stdout }}' question='mysql-server/root_password_again' vtype='password' value='{{ mysql_root_password }}'
when: not mysql_exists.stat.exists
- name: APT | Install MySQL server
apt: update_cache=yes cache_valid_time=3600 pkg=mysql-server state=latest
apt: pkg=mysql-server state=latest

View File

@ -1,13 +1,5 @@
---
- name: SHELL | Prepare MariaDB silent installation (root password)
shell: echo 'mariadb-server-{{ mariadb_version }} mysql-server/root_password password {{ mysql_root_password }}' | debconf-set-selections
when: not mysql_exists.stat.exists
- name: SHELL | Prepare MariaDB silent installation (root password again)
shell: echo 'mariadb-server-{{ mariadb_version }} mysql-server/root_password_again password {{ mysql_root_password }}' | debconf-set-selections
when: not mysql_exists.stat.exists
- name: APT | Install MariaDB key
apt_key: keyserver="keyserver.ubuntu.com" id="0xcbcb082a1bb943db" state=present
@ -17,6 +9,6 @@
- name: APT | Add MariaDB (src) repository
apt_repository: repo='deb-src {{ mariadb_repository }} {{ ansible_distribution_release }} main' state=present
- name: APT | Install MariaDB
apt: update_cache=yes cache_valid_time=3600 pkg=mariadb-server state=latest
- name: INCLUDE | Normal Install
include: install_default_mariadb.yml

View File

@ -1,8 +1,8 @@
---
- name: APT_KEY | Install Percona key
#apt_key: keyserver="keys.gnupg.net" id="1C4CBDCDCD2EFD2A" state=present
apt_key: keyserver="keyserver.ubuntu.com" id="1C4CBDCDCD2EFD2A" state=present
#apt_key: keyserver="keys.gnupg.net" id="1C4CBDCDCD2EFD2A" state=present
- 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
@ -13,14 +13,12 @@
- name: APT_RESPOSITORY | Add Percona (src) repository
apt_repository: repo='deb-src {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
# TODO: https://gist.github.com/mbbx6spp/3866962
- name: SHELL | Prepare Percona silent installation (root password)
shell: echo 'percona-server-server-{{ percona_version }} percona-server-server/root_password password {{ mysql_root_password }}' | debconf-set-selections
- 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 }}'
when: not mysql_exists.stat.exists
- name: SHELL | Prepare Percona silent installation (root password again)
shell: echo 'percona-server-server-{{ percona_version }} percona-server-server/root_password_again password {{ mysql_root_password }}' | debconf-set-selections
- name: DEBCONF | Prepare MySQL silent installation (root password)
debconf: name='percona-server-server-{{ percona_version }}' question='percona-server-server/root_password_again' vtype='password' value='{{ mysql_root_password }}'
when: not mysql_exists.stat.exists
- name: APT | Install Percona

View File

@ -3,10 +3,6 @@
- name: INCLUDE_VARS | Related to Debian version
include_vars: "{{ ansible_distribution_release }}.yml"
- name: FAIL | Check if packet is available
fail: msg='IMPOSSIBLE'
when: not "{{ mysql_origin }}_{{ mysql_vendor }}"
- name: STAT | Check if mysql exists
stat: path=/etc/init.d/mysql
register: mysql_exists