the python mysqldb module is required

Hi,

I have a problem with ansible 1.4.1 and 1.4.3.

When I start my playbook with a MySQL_db task, it says:

the python mysqldb module is required

But, in the target host, the module is present :

$ python
Python 2.7.6 (default, Jan 2 2014, 13:21:14)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
Type “help”, “copyright”, “credits” or “license” for more information.

import MySQLdb

The target host is a FreeBSD-9.2-RELEASE

What is the problem ? thanks you

The problem is that you need to install the python mysqldb module to use the Ansible module.

You can install this using OS packages (preferred) or pip.

I installed. Look my import exemple. There is no exception.
I said ‘target’ host but I installed on the ‘server’ host too.

The module is required where the task is being run, which is likely the remote host.

“There is no exception.”

Yep, this is what I’d expect too! that means we are catching the error and presenting you a human readable warning instead of a traceback.

ok, so the module is installed on my remote host.
How can I have the traceback ? The module works manually not with ansible.

You don’t want the traceback, proper error handling is better.

Please show the steps you have taken to have the module installed on the remote host, and the snippet of your playbook that uses it.

On my freebsd host “pkg install Py27èMySQLdb-1.2.3_2”

My task :

  • name: create db
    mysql_db:
    name: “{{ item.1 }}”
    login_host: “myhost”
    login_password: “mypassword”
    login_user: “root”
    state: present
    with_subelements:
  • users
  • db
    tags:
  • db

For those confused by the formatting in the last email, and finding this through google, here the FreeBSD command:

pkgng: name=databases/py-MySQLdb state=present