Initial commit

This commit is contained in:
Ansible Core Team 2020-03-09 09:11:07 +00:00
commit aebc1b03fd
4861 changed files with 812621 additions and 0 deletions

View file

@ -0,0 +1,21 @@
repo_link: https://repo.mysql.com/mysql80-community-release-el{{ ansible_facts.distribution_major_version }}.rpm
my_cnf: /etc/my.cnf
mysql_data_dirs:
- /var/lib/mysql
- /usr/mysql
mysql_support_packages:
- MySQL-python
mysql_server_packages:
- mysql-community-server
mysql_cleanup_packages:
- mysql-community-client
- mysql-community-common
- mysql-community-libs
- mysql-community-libs-compat
- mysql-community-server
- mysql80-community-release
- python3-PyMySQL

View file

@ -0,0 +1,7 @@
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default_authentication_plugin=mysql_native_password
skip-grant-tables

View file

@ -0,0 +1,29 @@
- name: stop mysql service
service:
name: mysqld
state: stopped
listen: cleanup mysql8
- name: remove repo
# yum:
# name: mysql80-community-release
# state: absent
# Work around for a bug in the dnf module. Use the module once that gets fixed.
# https://github.com/ansible/ansible/issues/64294
command: "{{ ansible_facts.pkg_mgr}} -y erase mysql80-community-release"
args:
warn: no
listen: cleanup mysql8
- name: remove mysql packages
yum:
name: '{{ mysql_support_packages | union(mysql_server_packages) | union(mysql_cleanup_packages) }}'
state: absent
listen: cleanup mysql8
- name: remove mysql data
file:
path: "{{ item }}"
state: absent
loop: "{{ mysql_data_dirs }}"
listen: cleanup mysql8

View file

@ -0,0 +1,18 @@
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Setup MySQL 8:
- name: Include distribution specific variables
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml'
- '{{ ansible_facts.os_family }}.yml'
- 'default.yml'
paths: vars
- import_tasks: setup_mysql8.yml
when:
- ansible_facts.distribution == 'CentOS'
- ansible_facts.distribution_major_version is version_compare('7', '>=')

View file

@ -0,0 +1,66 @@
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Install MySQL repo
yum:
name: '{{ repo_link }}'
notify: cleanup mysql8
# These packages come from AppStream in RHEL 8, so they need to be done in a separate task
- name: Install MySQL support packages
yum:
name: "{{ mysql_support_packages }}"
notify: cleanup mysql8
- name: Install MySQL community server
yum:
name: '{{ mysql_server_packages }}'
disablerepo: '{{ mysql_disablerepo | default(omit) }}'
notify: cleanup mysql8
- name: Copy my.cnf
copy:
src: my.cnf
dest: '{{ my_cnf }}'
- name: Start MySQL
service:
name: mysqld
state: started
### Debug #######################
#- name: Debug
# shell: cat /var/log/mysqld.log
#################################
- name: Check connection to the server
shell: 'echo "SHOW DATABASES;" | mysql'
- name: Check connection to the server
shell: "echo \"SHOW VARIABLES LIKE '%version%';\" | mysql"
- name: Detect socket path
shell: 'echo "show variables like ''socket''\G" | mysql | grep ''Value: '' | sed ''s/[ ]\+Value: //'''
register: _socket_path
- name: Set socket path
set_fact:
mysql_socket: '{{ _socket_path["stdout"] }}'
- name: Set root pass
set_fact:
root_pass: "dlsafjlkjdsaK1#"
- name: Set root password
shell: 'echo "flush privileges; ALTER USER ''root''@''localhost'' IDENTIFIED WITH mysql_native_password BY ''{{ root_pass }}'';" | mysql'
- name: Change configuration
lineinfile:
path: '{{ my_cnf }}'
line: skip-grant-tables
state: absent
- name: Restart MySQL
service:
name: mysqld
state: restarted

View file

@ -0,0 +1,4 @@
mysql_support_packages:
- python3-PyMySQL
mysql_disablerepo: AppStream

View file

@ -0,0 +1,3 @@
mysql_data_dirs:
- /var/lib/mysql
- /usr/share/mysql

View file

@ -0,0 +1,4 @@
mysql_support_packages:
- python3-PyMySQL
mysql_disablerepo: rhel-8-for-x86_64-appstream-rpms