bertvv / ansible-role-mariadb

Install MariaDB on RHEL/CentOS 7 or Fedora.
https://galaxy.ansible.com/bertvv/mariadb/
Other
144 stars 108 forks source link

Value not written to custom.cnf when 0 #28

Closed ghost closed 4 years ago

ghost commented 5 years ago

Hi,

When the custom.cnf file is generated, if a key-value mapping has a numerical value greater than 0 then {{ key }}={{ value }} is written to file, else only {{ key }} is written.

mariadb_custom_cnf: mysqld: server_id: '{{ groups[mariadb_servers].index(inventory_hostname) | int + 1 }}' log_bin: 'mysqld-bin' replicate-same-server-id: 0 replicate-do-db: 'testdb'

Generated custom.cnf file [mysqld] server_id=1 log_bin=mysqld-bin replicate-same-server-id (expected : replicate-same-server-id=0, as per the MariaDB documentation) replicate-do-db=testdb

Would it be possible to look into this "issue" for a future release?

Thank you in advance.

Kinds regards,

bertvv commented 4 years ago

It's best to consider all values, even numerical ones, as strings:

mariadb_custom_cnf:
  mysqld:
    server_id: '{{ groups[mariadb_servers].index(inventory_hostname) | int + 1 }}'
    log_bin: 'mysqld-bin'
    replicate-same-server-id: "0"  # Enter numbers as strings
    replicate-do-db: 'testdb'

I'll update the documentation to warn users for this.