|
import os
import time
#import sqlite3
#import redis
import json
dbname = '/tmp/setup.db'
TIME_FORMAT='%Y-%m-%d %H:%M:%S'
try:
con = sqlite3.connect(dbname)
cur = con.cursor()
except:
pass
def log(host, data):
pass
# 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):
#host=host=res._host.get_name()
#r = redis.Redis(host='127.0.0.1', port=6379, db=0)
#r.set(host,str(res))
f = open('/tmp/11','a')
f.write(str(host))
f.write(str(res))
f.close()
log(host, res)
def runner_on_failed(self, host, res, ignore_errors=False):
log(host, res) |
|
|