mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-02-24 10:13:30 +07:00
first commit
This commit is contained in:
0
tasks/install_default_mariadb.yml
Normal file
0
tasks/install_default_mariadb.yml
Normal file
0
tasks/install_default_mysql.yml
Normal file
0
tasks/install_default_mysql.yml
Normal file
0
tasks/install_percona_percona.yml
Normal file
0
tasks/install_percona_percona.yml
Normal file
0
tasks/installmariadb_mariadb.yml
Normal file
0
tasks/installmariadb_mariadb.yml
Normal file
56
tasks/main.yml
Normal file
56
tasks/main.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
|
||||
- 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: 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
|
||||
|
||||
- name: TEMPLATE Create .my.cnf for root
|
||||
template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes
|
||||
|
||||
- name: INCLUDE | Secure install
|
||||
include: 'secure.yml'
|
||||
|
||||
- name: MYSQL_DB | Create databases
|
||||
mysql_db: name={{ item }} state=present
|
||||
with_items: mysql_databases
|
||||
|
||||
- name: MYSQL_USER | Manages users...
|
||||
mysql_user: name={{ item.name }} password={{ item.password }} priv={{ item.priv }} state=present
|
||||
with_items: mysql_users
|
||||
|
||||
21
tasks/secure.yml
Normal file
21
tasks/secure.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
|
||||
- name: MYSQL_USER | Update mysql root password for all root accounts
|
||||
mysql_user: name=root host={{ item }} password={{ mysql_root_password }}
|
||||
with_items:
|
||||
- "{{ ansible_hostname }}"
|
||||
- 127.0.0.1
|
||||
- ::1
|
||||
- localhost
|
||||
|
||||
- name: MYSQL_USER | Remove all anonymous users
|
||||
mysql_user: name='' host={{ item }} state=absent
|
||||
with_items:
|
||||
- "{{ ansible_hostname }}"
|
||||
- 127.0.0.1
|
||||
- ::1
|
||||
- localhost
|
||||
|
||||
- name: MYSQL_DB | Remove the test database
|
||||
mysql_db: name=test state=absent
|
||||
|
||||
Reference in New Issue
Block a user