Add an inventory plugin to fetch groups and host from our CMDB.
This commit is contained in:
parent
c64193b4c6
commit
f023a2f3df
1 changed files with 46 additions and 0 deletions
46
plugins/inventory/ez.py
Executable file
46
plugins/inventory/ez.py
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env python
|
||||
# (c) 2012, Gregory Duchatelet <greg@2lm.fr>
|
||||
######################################################################
|
||||
|
||||
|
||||
import sys
|
||||
import xmlrpclib
|
||||
import shlex
|
||||
|
||||
try:
|
||||
import json
|
||||
except:
|
||||
import simplejson as json
|
||||
|
||||
import os
|
||||
import logging
|
||||
sys.path.insert (1, os.path.abspath("%s/svn_sysadmin/ezscripts/lib/python"%os.environ["HOME"]))
|
||||
sys.path.insert (2, '/usr/local/ez/lib/python')
|
||||
from ez_admin import *
|
||||
|
||||
|
||||
###################################################
|
||||
# executed with no parameters, return the list of
|
||||
# all groups and hosts
|
||||
|
||||
if len(sys.argv) == 2 and (sys.argv[1] == '--list'):
|
||||
logging.root.setLevel(logging.INFO)
|
||||
server = EzServer(None, False)
|
||||
print json.dumps(server.list_ansible())
|
||||
sys.exit(0)
|
||||
|
||||
#####################################################
|
||||
# executed with a hostname as a parameter, return the
|
||||
# variables for that host
|
||||
|
||||
elif len(sys.argv) == 3 and (sys.argv[1] == '--host'):
|
||||
# TODO: not yet implemented...
|
||||
print json.dumps({})
|
||||
#server.set_list_format("json")
|
||||
#print server.list_hosts(sys.argv[2])
|
||||
sys.exit(0)
|
||||
|
||||
else:
|
||||
print "usage: --list ..OR.. --host <hostname>"
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in a new issue