1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/usr/bin/env python
- import json
- import sys
- inventory = {
- "usa": {
- "children": [
- "southeast",
- ]
- },
- "southeast": {
- "children": [
- "atlanta",
- "raleigh",
- ],
- "vars": {
- "some_server": "foo.southeast.example.com",
- "halon_system_timeout": 30,
- "self_destruct_countdown": 60,
- "escape_pods": 2,
- }
- },
- "raleigh": [
- "host2",
- "host3",
- ],
- "atlanta": [
- "host1",
- "host2",
- ],
- }
- hostvars = {
- "host1": {
- },
- "host2": {
- },
- "host3": {
- }
- }
- if '--host' in sys.argv:
- print(json.dumps(hostvars.get(sys.argv[-1], {})))
- if '--list' in sys.argv:
- print(json.dumps(inventory))
|