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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dbb58e41-7b4d-4868-b4a2-d2e9157c7a40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to