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

- name: Read SQL configuration
  set_fact:
    sql_content: "{{ lookup('template', '{{ role_path }}/templates/sql.j2') }}"
  no_log: true

- name: Integration SQL configuration
  copy:
    dest: /tmp/file.sql
    content: '{{ sql_content }}'

- name: Set ProxySQL admin config
  shell: "mysql -u admin -padmin -h 127.0.0.1 -P 6032 < /tmp/file.sql"
  no_log: true

- name: Remove file
  file:
    path: /tmp/file.sql
    state: absent
