MySQL DB module behavior

Hello,

I need somes precisions about mysql_db module. I try to create Apache Guacamole role.

This is my playbook:

FIRST TASK:

  • name: Creation databases guacamole
    community.mysql.mysql_db:
    login_host: “{{ database_ip }}”
    login_user: root
    login_password: “{{ mariadb_root_pass }}”
    name: “guacamole_db”
    encoding: utf8
    state: present

SECOND TASK:

  • name: Install database MySQL
    community.mysql.mysql_db:
    login_host: “{{ database_ip }}”
    login_user: root
    login_password: “{{ mariadb_root_pass }}”
    name: “guacamole_db”
    state: import
    target: “/srv/live/{{ app_name }}/initdb.sql”

When variable “{{ database_ip }}” is set to localhost
First Task works,

Second Task,

I get this error:

“msg”: “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)\n”

When variable “{{ database_ip }}” is set to 127.0.0.1
Two tasks work.

My MariaDB is in Docker with port 3306 expose.

Thanks