mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
Merge pull request #12532 from fboender/devel
Output proper JSON from vbox dynamic inventory contrib script
This commit is contained in:
commit
4c7843f268
1 changed files with 6 additions and 2 deletions
|
@ -23,6 +23,11 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
class SetEncoder(json.JSONEncoder):
|
||||||
|
def default(self, obj):
|
||||||
|
if isinstance(obj, set):
|
||||||
|
return list(obj)
|
||||||
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
VBOX="VBoxManage"
|
VBOX="VBoxManage"
|
||||||
|
|
||||||
|
@ -110,5 +115,4 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
inventory = get_hosts()
|
inventory = get_hosts()
|
||||||
|
|
||||||
import pprint
|
sys.stdout.write(json.dumps(inventory, indent=2, cls=SetEncoder))
|
||||||
pprint.pprint(inventory)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue