mrlesmithjr / ansible-mariadb-galera-cluster

MIT License
136 stars 116 forks source link

wondering how to make changes like datadir (and some more overrides)... #235

Open kkplein opened 1 week ago

kkplein commented 1 week ago

This is my first use of roles, so far I've only written ansible playbooks without roles, and they are great! Thank you, for making this galera role available.

I added vars for almalinux-9, and I changed some bits to be able to use the stock mariadb-galera packages instead of the external MariaDB repo, and it all works so nice, and I've learned so much while doing it. Thank you!

Now my two small requests for some help.

1) I am trying to make some small changes to the generated galera install, like datadir=/data/mysql, and no matter where I change it, it always goes to /var/lib/mysql. How to do this? (i've tried ./defaults/mail.yml, ./templates/mysql/my.cnf.j2, i've tried setting "mariadb_mysql_settings_datadir=/data/mysql" in my inventory... nothing has any effect. How to do this?

2) I see the logic exists to create overides (./etc/mariadb_overrides.cnf.j2:{% for group, settings in mariadb_config_overrides.items() %}). How to make use of that..? What do I set, and where to best set it?

Probably the answer to both questions is related, and it's something I am missing and regular seasoned ansible role users know.

I would appreciate some short pointers. (or simple: links to working production examples that do these things, so I can learn from just reading those)

Again: thanks for making this role available!

kkplein commented 1 week ago

Meanwhile I have discovered how to achieve overrides. Using group_vars I was able to add mariadb_config_overrides to my inventory, and they are parsed and used.

But doing the same for mariadb_mysql_settings has no effect, unfortunately:

mariadb_mysql_settings:
  datadir: "/data/mysql"
  key_buffer_size: "{{ (ansible_memtotal_mb | int * mariadb_mysql_mem_multiplier) | round | int }}M"
  log_error: "/data/log/mysql/error.log"
  max_allowed_packet: "16M"
  max_binlog_size: "100M"
  query_cache_limit: "1M"
  query_cache_size: "16M"
  thread_cache_size: 256

mariadb_config_overrides:
  mariadb:
    max_connections: 2048
    innodb_buffer_pool_size: "1G"
    query_cache_size: "64M"
    wsrep_notify_cmd: "/usr/local/bin/wsrep_notify.sh"
kkplein commented 21 hours ago

Alas, no help. :-(

I have now edited the two templates from the role (etc/my.cnf.d/server.cnf.j2 and server.cnf.temp.j2) to include this code:

{% for group, settings in mariadb_mysql_settings.items() %}

[{{ group }}] {% for key, value in settings.items() %} {{ key }} = {{ value }} {% endfor %}

{% endfor %}

That works for us. Not sure why the regular galaxy-installed version of the script seems to ignore the values in mariadb_mysql_settings.