---
- name: Get MySQL version.
  command: 'mysql --version'
  register: mysql_cli_version
  changed_when: false
  check_mode: false

- name: Setup Mariadb config file
  template:
    src: server.j2
    dest: "{{ mariadb_config_file }}"
    owner: "{{ mariadb_config_file_owner }}"
    group: "{{ mariadb_config_file_group }}"
    mode: 0644

- name: Setup Galera config file if needed
  template:
    src: galera.j2
    dest: "{{ galera_config_file }}"
    owner: "{{ mariadb_config_file_owner }}"
    group: "{{ mariadb_config_file_group }}"
    mode: 0644
  when: groups['db_servers'] | length > 1
