Changeset - 2e3f14bc1505
[Not reviewed]
1 5 1
Branko Majic (branko) - 2 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
 
@@ -2064,12 +2064,13 @@ This role has no parameters.
 
Distribution compatibility
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Role is compatible with the following distributions:
 

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

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
This role has no parameters which can be configured configure.
roles/database_server/files/utf8.cnf
Show inline comments
 
deleted file
roles/database_server/meta/main.yml
Show inline comments
 
@@ -9,6 +9,7 @@ galaxy_info:
 
  license: BSD
 
  min_ansible_version: 2.9
 
  platforms:
 
    - name: Debian
 
      versions:
 
        - 11
 
        - 12
roles/database_server/molecule/default/molecule.yml
Show inline comments
 
@@ -20,12 +20,21 @@ platforms:
 
    box: debian/bullseye64
 
    memory: 512
 
    cpus: 1
 
    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:
 
    defaults:
 
      force_valid_group_names: "ignore"
 
      interpreter_python: "/usr/bin/python3"
roles/database_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -44,24 +44,31 @@ def test_utf8_configuration_file(host):
 

	
 
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
 

	
 
        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
 
@@ -12,14 +12,14 @@
 
  service:
 
    name: mysql
 
    state: started
 
    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
 
    mode: 0644
 
  register: mariadb_utf8_configuration
 

	
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)