Changeset - 2e3f14bc1505
[Not reviewed]
1 5 1
Branko Majic (branko) - 8 months ago 2024-02-27 00:15:55
branko@majic.rs
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.
7 files changed with 42 insertions and 13 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -2067,6 +2067,7 @@ Distribution compatibility
 
Role is compatible with the following distributions:
 

	
 
- Debian 11 (Bullseye)
 
- Debian 12 (Bookworm)
 

	
 

	
 
Examples
roles/database_server/files/utf8.cnf
Show inline comments
 
deleted file
roles/database_server/meta/main.yml
Show inline comments
 
@@ -12,3 +12,4 @@ galaxy_info:
 
    - name: Debian
 
      versions:
 
        - 11
 
        - 12
roles/database_server/molecule/default/molecule.yml
Show inline comments
 
@@ -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:
roles/database_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -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]
roles/database_server/tasks/main.yml
Show inline comments
 
@@ -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
roles/database_server/templates/utf8.cnf.j2
Show inline comments
 
new file 100644
 
{% 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 %}
0 comments (0 inline, 0 general)