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