roster.py 693 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import absolute_import
  4. import json
  5. import sys
  6. inventory = {
  7. "usa": {"children": ["southeast"]},
  8. "southeast": {
  9. "children": ["atlanta", "raleigh"],
  10. "vars": {
  11. "some_server": "foo.southeast.example.com",
  12. "halon_system_timeout": 30,
  13. "self_destruct_countdown": 60,
  14. "escape_pods": 2,
  15. },
  16. },
  17. "raleigh": ["host2", "host3"],
  18. "atlanta": ["host1", "host2"],
  19. }
  20. hostvars = {"host1": {}, "host2": {}, "host3": {}}
  21. if "--host" in sys.argv:
  22. print(json.dumps(hostvars.get(sys.argv[-1], {})))
  23. if "--list" in sys.argv:
  24. print(json.dumps(inventory))