# Call back script problems

**URL:** <https://forum.ansible.com/t/call-back-script-problems/20779>\
**Category:** Ansible Project\
**Created:** [March 4, 2016, 11:40pm UTC](https://forum.ansible.com/t/call-back-script-problems/20779 "2016-03-04T23:40:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Rosca](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@Gabriel\_Rosca](https://forum.ansible.com/u/Gabriel_Rosca)\
**Post date:** [March 4, 2016, 11:40pm UTC](https://forum.ansible.com/t/call-back-script-problems/20779/1 "2016-03-04T23:40:23Z")

</div>

Hi Guys,

I have this callback script. I add callback\_whitelist = inventory in ansible.cfg but when I an run get:

[WARNING]: Failure when attempting to use callback plugin (\</usr/share/ansible\_plugins/callback\_plugins/inventory.CallbackModule object at 0x22a0110\>):  
runner\_on\_ok() takes exactly 3 arguments (2 given)

Any Idea ?

#!/usr/bin/python  
import os  
import time  
import sqlite3

dbname = ‘/etc/ansible/setup.db’  
TIME\_FORMAT=‘%Y-%m-%d %H:%M:%S’

try:  
con = sqlite3.connect(dbname)  
cur = con.cursor()  
except:  
pass

def log(host, data):

if type(data) == dict:  
invocation = data.pop(‘invocation’, None)  
if invocation.get(‘module\_name’, None) != ‘setup’:  
return

facts = data.get(‘ansible\_facts’, None)

now = time.strftime(TIME\_FORMAT, time.localtime())

try:

# `host` is a unique index

cur.execute(“REPLACE INTO inventory (now, host, arch, dist, distvers, sys,kernel) VALUES(?,?,?,?,?,?,?);”,  
(  
now,  
facts.get(‘ansible\_hostname’, None),  
facts.get(‘ansible\_architecture’, None),  
facts.get(‘ansible\_distribution’, None),  
facts.get(‘ansible\_distribution\_version’, None),  
facts.get(‘ansible\_system’, None),  
facts.get(‘ansible\_kernel’, None)  
))  
con.commit()  
except:  
pass

class CallbackModule(object):  
def runner\_on\_ok(self, host, res):  
log(host, res)

Regards,  
Gabriel

---

<div class="post-metadata">

**Author:** ![Vincent\_Woo](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@Vincent\_Woo](https://forum.ansible.com/u/Vincent_Woo)\
**Post date:** [March 5, 2016, 1:42am UTC](https://forum.ansible.com/t/call-back-script-problems/20779/2 "2016-03-05T01:42:56Z")

</div>

I’m also seeing this right now.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 5, 2016, 4:42am UTC](https://forum.ansible.com/t/call-back-script-problems/20779/3 "2016-03-05T04:42:07Z")

</div>

first, you don’t need to whitelist custom callbacks, that is only for those shipped with ansible as they are disabled by default.

As for the error, you either need to implement all the v2 callbacks and use that to call runner\_on\_ok or you need to inherit from the new callback base.
