mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-25 15:31:45 -07:00
initial commit
This commit is contained in:
parent
9fcbbaad81
commit
76a1adffef
108 changed files with 8729 additions and 42 deletions
18
tests/integration/setup_mysql8/tasks/main.yml
Normal file
18
tests/integration/setup_mysql8/tasks/main.yml
Normal 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', '>=')
|
71
tests/integration/setup_mysql8/tasks/setup_mysql8.yml
Normal file
71
tests/integration/setup_mysql8/tasks/setup_mysql8.yml
Normal file
|
@ -0,0 +1,71 @@
|
|||
# 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 PyMySQL package via pip
|
||||
pip:
|
||||
name: PyMySQL
|
||||
state: present
|
||||
|
||||
- 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
|
Loading…
Add table
Add a link
Reference in a new issue