Can't set root password after fresh installation of mariadb using ansible
Solution:
We need to add login_unix_socket: /var/run/mysqld/mysqld.sock to the task:
- name: update mysql root password for root account
  mysql_user:
    name: root
    login_unix_socket: /var/run/mysqld/mysqld.sock
    host: 'localhost'
    password: '{{ mysql_root_password }}'
    priv: &quot;*.*:ALL,GRANT&quot;
    check_implicit_admin: true

Explanation:
The passwordless login is not possible when connecting through the network (this is what ansible does), only when connecting using the unix socket (the mysql CLI does that when connecting to localhost). So we need to force ansible to connect to the socket.
I hope this post saves somebody the time figuring that out.