From 2e3f14bc1505c39ecfa8e7d10773633de1a50cc9 2024-02-27 00:15:55 From: Branko Majic Date: 2024-02-27 00:15:55 Subject: [PATCH] MAR-192: Added support for Debian 12 Bookworm to database_server role: - Newer versions of MariaDB are planning on making the utf8 become a default alias for utf8mb4. Stick to utf8mb3 currently for compatibility purposes. --- diff --git a/docs/rolereference.rst b/docs/rolereference.rst index c2717a4eb2c81e201f25f414a75fcc48c4536860..9eb2cba11300006160f19e2529d0961600965158 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -2067,6 +2067,7 @@ Distribution compatibility Role is compatible with the following distributions: - Debian 11 (Bullseye) +- Debian 12 (Bookworm) Examples diff --git a/roles/database_server/files/utf8.cnf b/roles/database_server/files/utf8.cnf deleted file mode 100644 index 41699997f9c3973909c3edcffcf9c1c5c1364f7e..0000000000000000000000000000000000000000 --- a/roles/database_server/files/utf8.cnf +++ /dev/null @@ -1,8 +0,0 @@ -[client] -default-character-set = utf8 - -[mysqld] -character-set-server = utf8 -collation-server = utf8_general_ci -character_set_server = utf8 -collation_server = utf8_general_ci diff --git a/roles/database_server/meta/main.yml b/roles/database_server/meta/main.yml index fdf48d6ea1f5ba86a50afd0a66c24297c7bb15c9..9d1b6953c040e804826c57bde14534d899574f94 100644 --- a/roles/database_server/meta/main.yml +++ b/roles/database_server/meta/main.yml @@ -12,3 +12,4 @@ galaxy_info: - name: Debian versions: - 11 + - 12 diff --git a/roles/database_server/molecule/default/molecule.yml b/roles/database_server/molecule/default/molecule.yml index aa895e1f0f661c6e8deccd137bb032c13388a7ab..50217ebb3c3e09d28768ddbc571dff625c92b86d 100644 --- a/roles/database_server/molecule/default/molecule.yml +++ b/roles/database_server/molecule/default/molecule.yml @@ -23,6 +23,15 @@ platforms: provider_raw_config_args: - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']" + - name: parameters-mandatory-bookworm + groups: + - parameters-mandatory + box: debian/bookworm64 + memory: 512 + cpus: 1 + provider_raw_config_args: + - "customize ['modifyvm', :id, '--paravirtprovider', 'minimal']" + provisioner: name: ansible config_options: diff --git a/roles/database_server/molecule/default/tests/test_default.py b/roles/database_server/molecule/default/tests/test_default.py index e817df811b0988c8270ae5aedea8e624c026c15e..8d56e2f6f25a3af5e87ca7043a53cf7cfb889d00 100644 --- a/roles/database_server/molecule/default/tests/test_default.py +++ b/roles/database_server/molecule/default/tests/test_default.py @@ -47,6 +47,13 @@ def test_utf8_configuration(host): Tests if UTF-8 configuration has been applied correctly to server. """ + expected_character_set_and_collation = { + "bullseye": "utf8\nutf8_general_ci\n", + "bookworm": "utf8mb3\nutf8mb3_general_ci\n", + } + + distribution_release = host.ansible("setup")["ansible_facts"]["ansible_distribution_release"] + with host.sudo(): assert host.run("mysql -uroot -BNe 'drop database if exists test'").rc == 0 assert host.run("mysql -uroot -BNe 'create database test'").rc == 0 @@ -54,14 +61,14 @@ def test_utf8_configuration(host): check_server = host.run("mysql -uroot test -BNe 'select @@character_set_server; select @@collation_server'") assert check_server.rc == 0 - assert check_server.stdout == "utf8\nutf8_general_ci\n" + assert check_server.stdout == expected_character_set_and_collation[distribution_release] check_database = host.run("mysql -uroot test -BNe 'select @@character_set_database; select @@collation_database'") assert check_database.rc == 0 - assert check_database.stdout == "utf8\nutf8_general_ci\n" + assert check_database.stdout == expected_character_set_and_collation[distribution_release] check_database = host.run("mysql -uroot -BNe 'select @@character_set_connection; select @@collation_connection'") assert check_database.rc == 0 - assert check_database.stdout == "utf8\nutf8_general_ci\n" + assert check_database.stdout == expected_character_set_and_collation[distribution_release] diff --git a/roles/database_server/tasks/main.yml b/roles/database_server/tasks/main.yml index 30dd4e2aaaec2eccf9756fbf4d179241f302ea95..b1af29cbd9b37bddc86fdeb204c7758075aa02c0 100644 --- a/roles/database_server/tasks/main.yml +++ b/roles/database_server/tasks/main.yml @@ -15,8 +15,8 @@ enabled: true - name: Set UTF-8 encoding as default for MariaDB - copy: - src: "utf8.cnf" + template: + src: "utf8.cnf.j2" dest: "/etc/mysql/mariadb.conf.d/90-utf8.cnf" owner: root group: root diff --git a/roles/database_server/templates/utf8.cnf.j2 b/roles/database_server/templates/utf8.cnf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ac1e31328b732d6da707878d595c0f56c6b5d684 --- /dev/null +++ b/roles/database_server/templates/utf8.cnf.j2 @@ -0,0 +1,19 @@ +{% if ansible_distribution_release == 'bullseye' %} +[client] +default-character-set = utf8 + +[mysqld] +character-set-server = utf8 +collation-server = utf8_general_ci +character_set_server = utf8 +collation_server = utf8_general_ci +{% else %} +[client] +default-character-set = utf8mb3 + +[mysqld] +character-set-server = utf8mb3 +collation-server = utf8mb3_general_ci +character_set_server = utf8mb3 +collation_server = utf8mb3_general_ci +{% endif %}