diff --git a/plugins/inventory/ez.py b/plugins/inventory/ez.py new file mode 100755 index 00000000000..fa0b6f0f53f --- /dev/null +++ b/plugins/inventory/ez.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# (c) 2012, Gregory Duchatelet +###################################################################### + + +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 " + sys.exit(1) +