mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-02-24 10:13:30 +07:00
Import tasks/defaults/templates/readme from old repo
This commit is contained in:
27
tasks/install.yml
Normal file
27
tasks/install.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
|
||||
- name: INCLUDE | Install MySQL from default repo
|
||||
include: 'install_default_mysql.yml'
|
||||
when: mysql_origin == 'default' mysql_vendor == 'mysql'
|
||||
|
||||
- name: INCLUDE | Install MariaDB from Debian repo
|
||||
include: 'install_default_mariadb.yml'
|
||||
when: mysql_origin == 'default' and mysql_vendor == 'mariadb'
|
||||
|
||||
- name: INCLUDE | Install MariaDB from MariaDB repo
|
||||
include: 'install_mariadb_mariadb.yml'
|
||||
when: mysql_origin == 'mariadb' and mysql_vendor == 'mariadb'
|
||||
|
||||
- name: INCLUDE | Install Percona Server from Percona repo
|
||||
include: 'install_percona_percona.yml'
|
||||
when: mysql_origin == 'percona' and mysql_vendor == 'percona'
|
||||
|
||||
- name: APT | Install few MySQL related tools
|
||||
apt: pkg={{ item }} state=latest
|
||||
with_items:
|
||||
- mytop
|
||||
- percona-toolkit
|
||||
- python-configparser
|
||||
- python-mysqldb
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
- 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
|
||||
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
|
||||
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
|
||||
when: not mysql_exists.stat.exists
|
||||
|
||||
- name: APT | Install MySQL server
|
||||
apt: update_cache=yes cache_valid_time=3600 pkg=mysql-server state=latest
|
||||
|
||||
|
||||
22
tasks/install_mariadb_mariadb.yml
Normal file
22
tasks/install_mariadb_mariadb.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
- 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
|
||||
|
||||
- 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: APT | Install MariaDB
|
||||
apt: update_cache=yes cache_valid_time=3600 pkg=mariadb-server state=latest
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
|
||||
- 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
|
||||
|
||||
- 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
|
||||
|
||||
# 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
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
@@ -7,35 +7,11 @@
|
||||
fail: msg='IMPOSSIBLE'
|
||||
when: not "{{ mysql_origin }}_{{ mysql_vendor }}"
|
||||
|
||||
- name: APT | Install few MySQL related tools
|
||||
apt: pkg={{ item }} state=latest
|
||||
with_items:
|
||||
- mytop
|
||||
- percona-toolkit
|
||||
- python-configparser
|
||||
- python-mysqldb
|
||||
|
||||
- name: STAT | Check if mysql exists
|
||||
stat: path=/etc/init.d/mysql
|
||||
register: mysql_exists
|
||||
changed_when: false
|
||||
|
||||
- name: INCLUDE | Install MySQL from default repo
|
||||
include: 'debian_mysql.yml'
|
||||
when: mysql_origin == 'default' mysql_vendor == 'mysql'
|
||||
|
||||
- name: INCLUDE | Install MariaDB from Debian repo
|
||||
include: 'debian_mariadb.yml'
|
||||
when: mysql_origin == 'default' and mysql_vendor == 'mariadb'
|
||||
|
||||
- name: INCLUDE | Install MariaDB from MariaDB repo
|
||||
include: 'mariadb_mariadb.yml'
|
||||
when: mysql_origin == 'default' and mysql_vendor == 'mariadb'
|
||||
|
||||
- name: INCLUDE | Install Percona Server from Percona repo
|
||||
include: 'percona_percona.yml'
|
||||
when: mysql_origin == 'percona' and mysql_vendor == 'percona'
|
||||
|
||||
- name: TEMPLATE | Deploy daemon configuration
|
||||
template: src=etc/mysql/conf.d/98-config.cnf.j2 dest=/etc/mysql/conf.d/98-config.cnf
|
||||
notify: restart mysql
|
||||
|
||||
Reference in New Issue
Block a user