Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
dest: "{{ mysql_config_file }}"
owner: root
group: root
mode: 0644
mode: 0600
force: "{{ overwrite_global_mycnf }}"
notify: restart mysql

Expand All @@ -29,6 +29,14 @@
with_items: "{{ mysql_config_include_files }}"
notify: restart mysql

- name: Create log dir if missing
file:
path: "{{mysql_log_dir}}"
state: directory
owner: mysql
group: mysql
mode: 0750

- name: Create slow query log file (if configured).
command: "touch {{ mysql_slow_query_log_file }}"
args:
Expand Down Expand Up @@ -67,9 +75,12 @@
state: file
owner: mysql
group: "{{ mysql_log_file_group }}"
mode: 0640
mode: 0755
when: mysql_log == "" and mysql_log_error != ""

- name: Startingg the MySQL service
action: service name=mysql state=started

- name: Ensure MySQL is started and enabled on boot.
service: "name={{ mysql_daemon }} state=started enabled={{ mysql_enabled_on_startup }}"
register: mysql_service_configuration
4 changes: 2 additions & 2 deletions tasks/secure-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
mysql -u root -NBe
'ALTER USER "{{ mysql_root_username }}"@"{{ item }}" IDENTIFIED WITH mysql_native_password BY "{{ mysql_root_password }}";'
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' in mysql_cli_version.stdout)
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' in mysql_cli_version.stdout or '8.0.' in mysql_cli_version.stdout)

# Set root password for MySQL < 5.7.x.
- name: Update MySQL root password for localhost root account (< 5.7.x).
shell: >
mysql -NBe
'SET PASSWORD FOR "{{ mysql_root_username }}"@"{{ item }}" = PASSWORD("{{ mysql_root_password }}");'
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' not in mysql_cli_version.stdout)
when: ((mysql_install_packages | bool) or mysql_root_password_update) and ('5.7.' not in mysql_cli_version.stdout) and ('8.0.' not in mysql_cli_version.stdout)

# Has to be after the root password assignment, for idempotency.
- name: Copy .my.cnf file with root password credentials.
Expand Down
2 changes: 1 addition & 1 deletion tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
register: mysql_installed

- name: Add repo.mysql.com apt key
apt_key: url=http://repo.mysql.com/RPM-GPG-KEY-mysql
apt_key: url=http://repo.mysql.com/RPM-GPG-KEY-mysql-2023
when: mysql_apt_repo_version is defined

- name: Add repo.mysql.com apt repo
Expand Down
5 changes: 4 additions & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ __mysql_daemon: mysql
__mysql_packages:
- mysql-common
- mysql-server
mysql_log_file_group: adm
- python3-pymysql
- default-libmysqlclient-dev
mysql_log_file_group: mysql
mysql_log_dir: /var/log/mysql
__mysql_slow_query_log_file: /var/log/mysql/mysql-slow.log
__mysql_log_error: /var/log/mysql/mysql.err
__mysql_syslog_tag: mysql
Expand Down