mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-02-24 10:13:30 +07:00
Install tasks in seperated directory
This commit is contained in:
18
tasks/install/default_mariadb.yml
Normal file
18
tasks/install/default_mariadb.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- 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: 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
|
||||
|
||||
- name: APT | Install MariaDB server
|
||||
apt: pkg=mariadb-server state=latest
|
||||
|
||||
18
tasks/install/default_mysql.yml
Normal file
18
tasks/install/default_mysql.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- name: SHELL | Get MySQL target version
|
||||
shell: LANG=C apt-cache depends mysql-server | awk -F '-' '/Depends/ { print $NF }'
|
||||
register: apt_mysql_version
|
||||
changed_when: false
|
||||
|
||||
- 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: DEBCONF | Prepare MySQL silent installation (root password again)
|
||||
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: pkg=mysql-server state=latest
|
||||
|
||||
50
tasks/install/main.yml
Normal file
50
tasks/install/main.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
|
||||
- name: FAIL | If config asked is impossible
|
||||
fail: msg="config asked is impossible origin -> {{ mysql_origin }} vendor -> {{ mysql_vendor }}"
|
||||
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 == 'upstream' and mysql_vendor == 'mariadb') or
|
||||
(mysql_origin == 'upstream' and mysql_vendor == 'percona')
|
||||
)
|
||||
|
||||
- name: APT_KEY | Install Percona key
|
||||
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
|
||||
|
||||
- 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
|
||||
include: 'default_mysql.yml'
|
||||
when: mysql_origin == 'default' and mysql_vendor == 'mysql'
|
||||
|
||||
- name: INCLUDE | Install MariaDB from Debian repo
|
||||
include: 'default_mariadb.yml'
|
||||
when: mysql_origin == 'default' and mysql_vendor == 'mariadb' and ansible_distribution_major_version > 7
|
||||
|
||||
- name: INCLUDE | Install MariaDB from MariaDB repo
|
||||
include: 'upstream_mariadb.yml'
|
||||
when: mysql_origin == 'upstream' and mysql_vendor == 'mariadb'
|
||||
|
||||
- name: INCLUDE | Install Percona Server from Percona repo
|
||||
include: 'upstream_percona.yml'
|
||||
when: mysql_origin == 'upstream' and mysql_vendor == 'percona'
|
||||
|
||||
- name: APT | Install few MySQL related tools
|
||||
apt: pkg={{ item }} state=latest
|
||||
with_items:
|
||||
- mytop
|
||||
- percona-toolkit
|
||||
- python-mysqldb
|
||||
- percona-xtrabackup
|
||||
- mysqltuner
|
||||
|
||||
14
tasks/install/upstream_mariadb.yml
Normal file
14
tasks/install/upstream_mariadb.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
|
||||
- name: APT | Install MariaDB key
|
||||
apt_key: keyserver="keyserver.ubuntu.com" id="0xcbcb082a1bb943db" state=present
|
||||
|
||||
- name: APT | Add MariaDB repository
|
||||
apt_repository: repo='deb {{ mariadb_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
|
||||
- name: APT | Add MariaDB (src) repository
|
||||
apt_repository: repo='deb-src {{ mariadb_repository }} {{ ansible_distribution_release }} main' state=present
|
||||
|
||||
- name: INCLUDE | Normal Install
|
||||
include: default_mariadb.yml
|
||||
|
||||
13
tasks/install/upstream_percona.yml
Normal file
13
tasks/install/upstream_percona.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
- 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: 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
|
||||
apt: update_cache=yes cache_valid_time=3600 pkg='percona-server-server-{{ percona_version }}' state=latest
|
||||
|
||||
Reference in New Issue
Block a user