Create MariaDB users and grant privileges

Hi,

I have the following task in an Ansible playbook :

- name: Create MariaDB users and grant privileges
  community.mysql.mysql_user:
    name: "{{item.user}}"
    password: "{{item.password}}"
    priv: "{{item.name}}.*:ALL"
    login_unix_socket: /var/run/mysqld/mysqld.sock
    column_case_sensitive: true
    state: present
  loop: "{{mariadb_databases}}"
  no_log: true

The playbook sets up a MariaDB database server, creates initial MariaDB users, etc.

Now the task in itself works. The problem is, it’s not idempotent, e. g. it reports a change every time the playbook is executed.

Any idea how to make this task idempotent ?

According to the docs it has full support (ansible.mysql.mysql_user module – Adds or removes a user from a MySQL or MariaDB database — Ansible Community Documentation).

With that said I’d turn logging back on and check whats reporting as different.