Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kyl191
Created January 18, 2015 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyl191/8f387ff14a6d6ea6201b to your computer and use it in GitHub Desktop.
Save kyl191/8f387ff14a6d6ea6201b to your computer and use it in GitHub Desktop.
Python Inventory file for Ansible
#!/usr/bin/python
from __future__ import print_function
import json
overarch = {}
overarch["us"] = [
"kc.example.com",
"la.example.net",
]
overarch["germany"] = ["de.test.net"]
overarch["france"] = ["fr.test.net"]
overarch["vps"] = {"children":["us", "germany"], "hosts":[]}
hostvars = {}
hostvars["kc.example.com"] = {"openvpn.port":17601}
hostvars["la.example.net"] = {"ansible_ssh_port":40000}
overarch["_meta"] = {"hostvars":hostvars}
print(json.dumps(overarch, sort_keys=True, indent=2, separators=(',', ': ')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment