Use a dictionary for config and read and write ini files
A combination of the JC ini parser and the Ansible community.general.ini_file module could be used to enable config for MariaDB to be written like this:
mariadb_config:
- path: /etc/mysql/mariadb.conf.d/50-server.cnf
config:
server: {}
mysqld:
user: mysql
pid-file: /var/run/mysqld/mysqld.pid
socket: /var/run/mysqld/mysqld.sock
port: '3306'
basedir: /usr
datadir: /var/lib/mysql
tmpdir: /tmp
lc-messages-dir: /usr/share/mysql
skip-external-locking: ''
bind-address: 127.0.0.1
key_buffer_size: 32M
max_allowed_packet: 64M
thread_stack: 192K
thread_cache_size: '8'
myisam_recover_options: BACKUP
max_connections: '80'
max_user_connections: '0'
table_cache: '64'
thread_concurrency: '10'
open_files_limit: '122880'
table_open_cache: '6000'
tmp_table_size: 256M
join_buffer_size: 256K
max_heap_table_size: 256M
query_cache_type: '0'
query_cache_limit: '0'
query_cache_size: '0'
log_error: /var/log/mysql/error.log
expire_logs_days: '10'
max_binlog_size: 100M
innodb_buffer_pool_size: 3G
innodb_log_file_size: 768M
character-set-server: utf8mb4
collation-server: utf8mb4_general_ci
embedded: {}
mariadb:
performance_schema: ON
performance-schema-instrument: stage/%=ON
performance-schema-consumer-events-stages-current: ON
performance-schema-consumer-events-stages-history: ON
performance-schema-consumer-events-stages-history-long: ON
mariadb-10.1: {}
Which would make this role a lot more flexible.