Ansible playbook for creating mysql user not working

When running mysql_user module in ansible it is showing the below error.

ansible version - 2.6

mysql version - 5.6

yaml syntax :-

- name: Test | mysql
  mysql_user: name=test password=test host=localhost state=present

error :-


fatal: [94.130.87.130]: FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to 94.130.87.130 closed.\r\n", 
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_73s74m/ansible_module_mysql_user.py\", line 206, in <module>\r\n    from ansible.module_utils.basic import AnsibleModule\r\nzlib.error: Error -2 while preparing to decompress data: inconsistent stream state\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 1
}

That looks like an issue with the ssh connection. Can you try a couple of things:

  1. Verify that you can connect using ssh

  2. If you can, try a simple Ansible play like ‘ping’ and see if that works.

Andrew,

Thank You for your reply.The issue is not with the ssh connection.The above is only a portion of task that I am running.I was able to execute other tasks successfully.Still not sure why I am not able to get the required output.

I’m not familiar with that module, but do you have all the prereqs installed?

The Ansible docs say:

  • Both login_password and login_user are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of ‘root’ with no password.

MySQL server is having the user root with no password.