Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MySQL 8.4 #549

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
16 changes: 14 additions & 2 deletions tasks/secure-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
# Note: We do not use mysql_user for this operation, as it doesn't always update
# the root password correctly. See: https://goo.gl/MSOejW
# Set root password for MySQL >= 5.7.x.

- name: Update MySQL root password for localhost root account (8.x).
ansible.builtin.shell: >
mysql -u root -NBe
"ALTER USER '{{ mysql_root_username }}'@'{{ item }}'
IDENTIFIED WITH caching_sha2_password BY '{{ mysql_root_password }}'; FLUSH PRIVILEGES;"
no_log: "{{ mysql_hide_passwords }}"
with_items: "{{ mysql_root_hosts.stdout_lines|default([]) }}"
when: >
((mysql_install_packages | bool) or mysql_root_password_update)
and ('8.' in mysql_cli_version.stdout)

- name: Update MySQL root password for localhost root account (5.7.x).
ansible.builtin.shell: >
mysql -u root -NBe
Expand All @@ -50,7 +62,7 @@
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 or '8.0.' in mysql_cli_version.stdout)
and ('5.7.' 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).
Expand All @@ -61,7 +73,7 @@
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 and '8.0.' not in mysql_cli_version.stdout)
and ('5.7.' not in mysql_cli_version.stdout and '8.' not in mysql_cli_version.stdout)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only downside to this change is maybe the comparison would break if there were a version like 5.8.0, that version would be identified as 8.... trying to think of a better way to narrow it. Maybe add in something to trim off the first two digits, and compare that to 8.?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this solution, but as far as I know, version 5.8 doesn't exist. However, everything works fine on version >= 5.7. If you want, I can change the version definition using trim.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using trim would be ever so slightly more future proof. It feels more correct to me.


# Has to be after the root password assignment, for idempotency.
- name: Copy .my.cnf file with root password credentials.
Expand Down
4 changes: 2 additions & 2 deletions templates/my.cnf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ read_buffer_size = {{ mysql_read_buffer_size }}
read_rnd_buffer_size = {{ mysql_read_rnd_buffer_size }}
myisam_sort_buffer_size = {{ mysql_myisam_sort_buffer_size }}
thread_cache_size = {{ mysql_thread_cache_size }}
{% if '8.0.' not in mysql_cli_version.stdout %}
{% if '8.' not in mysql_cli_version.stdout %}
query_cache_type = {{ mysql_query_cache_type }}
query_cache_size = {{ mysql_query_cache_size }}
query_cache_limit = {{ mysql_query_cache_limit }}
Expand All @@ -104,7 +104,7 @@ lower_case_table_names = {{ mysql_lower_case_table_names }}
event_scheduler = {{ mysql_event_scheduler_state }}

# InnoDB settings.
{% if mysql_supports_innodb_large_prefix and '8.0.' not in mysql_cli_version.stdout %}
{% if mysql_supports_innodb_large_prefix and '8.' not in mysql_cli_version.stdout %}
innodb_large_prefix = {{ mysql_innodb_large_prefix }}
innodb_file_format = {{ mysql_innodb_file_format }}
{% endif %}
Expand Down
Loading