summaryrefslogtreecommitdiff
path: root/test/integration/targets/setup_mysql8/tasks/setup_mysql8.yml
blob: 7f95301b413d3563cc1bb8240ff2eee4166ea2ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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