mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
924 B
Python
41 lines
924 B
Python
13 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
import json
|
||
|
import sys
|
||
|
|
||
|
from optparse import OptionParser
|
||
|
|
||
|
parser = OptionParser()
|
||
|
parser.add_option('-l', '--list', default=False, dest="list_hosts", action="store_true")
|
||
|
parser.add_option('-H', '--host', default=None, dest="host")
|
||
|
parser.add_option('-e', '--extra-vars', default=None, dest="extra")
|
||
|
|
||
|
options, args = parser.parse_args()
|
||
|
|
||
|
systems = {
|
||
12 years ago
|
"ungrouped": [ "jupiter", "saturn" ],
|
||
13 years ago
|
"greek": [ "zeus", "hera", "poseidon" ],
|
||
12 years ago
|
"norse": [ "thor", "odin", "loki" ],
|
||
|
"major-god": [ "zeus", "odin" ],
|
||
13 years ago
|
}
|
||
|
|
||
|
variables = {
|
||
|
"thor": {
|
||
|
"hammer": True
|
||
12 years ago
|
},
|
||
|
"zeus": {},
|
||
13 years ago
|
}
|
||
|
|
||
|
if options.list_hosts == True:
|
||
|
print json.dumps(systems)
|
||
|
sys.exit(0)
|
||
|
|
||
|
if options.host is not None:
|
||
|
if options.extra:
|
||
|
k,v = options.extra.split("=")
|
||
|
variables[options.host][k] = v
|
||
|
print json.dumps(variables[options.host])
|
||
|
sys.exit(0)
|
||
|
|
||
|
parser.print_help()
|
||
|
sys.exit(1)
|