Unable to import MySQLdb in ansible module

23 views
Skip to first unread message

Roopendra Vishwakarma

unread,
Mar 7, 2014, 9:24:25 AM3/7/14
to ansible...@googlegroups.com
I am trying to write custom module in ansible. while using `import MySQLdb` it is giving me error

     failed: [127.0.0.1] => {"failed": true, "parsed": false}
    invalid output was: Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-1394199347.29-33439012674717/inventory", line 11, in <module>
        import MySQLdb
    ImportError: No module named MySQLdb

Using 
Python Version : 2.6.6 
MySQL-python Version : 1.2.3

Python Code:-

    #!/usr/bin/python

    import datetime
    import sys
    import json
    import os
    import shlex
    import MySQLdb

    db = MySQLdb.connect("localhost","user","pwd","db_name" )
    cursor = db.cursor()
    cursor.execute("SELECT * FROM hosts")
    data = cursor.fetchone()
    print data
    db.close()


Same code working in python command line (<<<) but not working in ansible module. 
Is there any configuration setting need to do for ansible??
Reply all
Reply to author
Forward
0 new messages