2019-10-16 08:30:33 +02:00
|
|
|
# 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)
|
|
|
|
|
2019-10-23 17:11:02 +02:00
|
|
|
- name: Install MySQL repo
|
2019-10-16 08:30:33 +02:00
|
|
|
yum:
|
|
|
|
name: '{{ repo_link }}'
|
2019-10-23 17:11:02 +02:00
|
|
|
notify: cleanup mysql8
|
2019-10-16 08:30:33 +02:00
|
|
|
|
|
|
|
- name: Install MySQL community server
|
|
|
|
yum:
|
2019-10-23 17:11:02 +02:00
|
|
|
name: '{{ mysql_packages }}'
|
|
|
|
notify: cleanup mysql8
|
2019-10-16 08:30:33 +02:00
|
|
|
|
|
|
|
- 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
|
2019-10-23 17:11:02 +02:00
|
|
|
shell: 'echo "show variables like ''socket''\G" | mysql | grep ''Value: '' | sed ''s/[ ]\+Value: //'''
|
2019-10-16 08:30:33 +02:00
|
|
|
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
|
2019-10-23 17:11:02 +02:00
|
|
|
shell: 'echo "flush privileges; ALTER USER ''root''@''localhost'' IDENTIFIED WITH mysql_native_password BY ''{{ root_pass }}'';" | mysql'
|
2019-10-16 08:30:33 +02:00
|
|
|
|
|
|
|
- name: Change configuration
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ my_cnf }}'
|
|
|
|
line: skip-grant-tables
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Restart MySQL
|
|
|
|
service:
|
|
|
|
name: mysqld
|
|
|
|
state: restarted
|