diff --git a/tasks/configure.yml b/tasks/configure.yml index 15185a3c..6c53f422 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -5,7 +5,7 @@ dest: "{{ mysql_config_file }}" owner: root group: root - mode: 0644 + mode: 0600 force: "{{ overwrite_global_mycnf }}" notify: restart mysql @@ -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: @@ -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 diff --git a/tasks/secure-installation.yml b/tasks/secure-installation.yml index c5843119..fd747611 100644 --- a/tasks/secure-installation.yml +++ b/tasks/secure-installation.yml @@ -43,7 +43,7 @@ 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). @@ -51,7 +51,7 @@ 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. diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 8bd7b1cc..630f156c 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -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 diff --git a/vars/Debian.yml b/vars/Debian.yml index a96a025c..4c518e87 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -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