MySQL and Percona works
parent
7b2439e590
commit
1da1c01446
|
@ -3,8 +3,8 @@
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
# Setup
|
# Setup
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
mysql_origin: 'default'
|
mysql_origin: 'mariadb'
|
||||||
mysql_vendor: 'mysql'
|
mysql_vendor: 'mariadb'
|
||||||
mysql_root_password: 'change_me_NOW'
|
mysql_root_password: 'change_me_NOW'
|
||||||
|
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
|
@ -29,7 +29,7 @@ mysql_users: []
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
mariadb_version: '10.0' # (5.5, 10.0)
|
mariadb_version: '10.0' # (5.5, 10.0)
|
||||||
# See: http://mariadb.org/mariadb/repositories/
|
# 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
|
# Percona
|
||||||
|
|
|
@ -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'
|
include: 'install_default_mysql.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: 'install_default_mariadb.yml'
|
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
|
- name: INCLUDE | Install MariaDB from MariaDB repo
|
||||||
include: 'install_mariadb_mariadb.yml'
|
include: 'install_mariadb_mariadb.yml'
|
||||||
|
@ -21,7 +34,5 @@
|
||||||
with_items:
|
with_items:
|
||||||
- mytop
|
- mytop
|
||||||
- percona-toolkit
|
- percona-toolkit
|
||||||
- python-configparser
|
|
||||||
- python-mysqldb
|
- python-mysqldb
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -2,18 +2,17 @@
|
||||||
|
|
||||||
- name: SHELL | Get MySQL target version
|
- name: SHELL | Get MySQL target version
|
||||||
shell: LANG=C apt-cache depends mysql-server | awk -F '-' '/Depends/ { print $NF }'
|
shell: LANG=C apt-cache depends mysql-server | awk -F '-' '/Depends/ { print $NF }'
|
||||||
register: mysql_version
|
register: apt_mysql_version
|
||||||
when: not mysql_exists.stat.exists
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: SHELL | Prepare MySQL silent installation (root password)
|
- name: DEBCONF | Prepare MySQL silent installation (root password)
|
||||||
shell: echo 'mysql-server-{{ mysql_version.stdout }} mysql-server/root_password password {{ mysql_root_password }}' | debconf-set-selections
|
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
|
when: not mysql_exists.stat.exists
|
||||||
|
|
||||||
- name: SHELL | Prepare MySQL silent installation (root password again)
|
- 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
|
when: not mysql_exists.stat.exists
|
||||||
|
|
||||||
- name: APT | Install MySQL server
|
- name: APT | Install MySQL server
|
||||||
apt: update_cache=yes cache_valid_time=3600 pkg=mysql-server state=latest
|
apt: pkg=mysql-server state=latest
|
||||||
|
|
||||||
|
|
|
@ -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
|
- name: APT | Install MariaDB key
|
||||||
apt_key: keyserver="keyserver.ubuntu.com" id="0xcbcb082a1bb943db" state=present
|
apt_key: keyserver="keyserver.ubuntu.com" id="0xcbcb082a1bb943db" state=present
|
||||||
|
|
||||||
|
@ -17,6 +9,6 @@
|
||||||
- name: APT | Add MariaDB (src) repository
|
- name: APT | Add MariaDB (src) repository
|
||||||
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: APT | Install MariaDB
|
- name: INCLUDE | Normal Install
|
||||||
apt: update_cache=yes cache_valid_time=3600 pkg=mariadb-server state=latest
|
include: install_default_mariadb.yml
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: APT_KEY | Install Percona key
|
- 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="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)
|
- 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
|
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
|
- name: APT_RESPOSITORY | Add Percona (src) repository
|
||||||
apt_repository: repo='deb-src {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
|
apt_repository: repo='deb-src {{ percona_repository }} {{ ansible_distribution_release }} main' state=present
|
||||||
|
|
||||||
# TODO: https://gist.github.com/mbbx6spp/3866962
|
- 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 }}'
|
||||||
- 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
|
|
||||||
when: not mysql_exists.stat.exists
|
when: not mysql_exists.stat.exists
|
||||||
|
|
||||||
- name: SHELL | Prepare Percona silent installation (root password again)
|
- name: DEBCONF | Prepare MySQL silent installation (root password)
|
||||||
shell: echo 'percona-server-server-{{ percona_version }} percona-server-server/root_password_again password {{ mysql_root_password }}' | debconf-set-selections
|
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
|
when: not mysql_exists.stat.exists
|
||||||
|
|
||||||
- name: APT | Install Percona
|
- name: APT | Install Percona
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
- name: INCLUDE_VARS | Related to Debian version
|
- name: INCLUDE_VARS | Related to Debian version
|
||||||
include_vars: "{{ ansible_distribution_release }}.yml"
|
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
|
- name: STAT | Check if mysql exists
|
||||||
stat: path=/etc/init.d/mysql
|
stat: path=/etc/init.d/mysql
|
||||||
register: mysql_exists
|
register: mysql_exists
|
||||||
|
|
Loading…
Reference in New Issue