Skip to content

Commit

Permalink
Merge pull request ansible#9312 from admiyo/freeipa
Browse files Browse the repository at this point in the history
Inventory Plugin to get hostgroups from FreeIPA
  • Loading branch information
mpdehaan committed Oct 13, 2014
2 parents edac9ad + 428674c commit c930ee4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/inventory/freeipa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python

import json
from ipalib import api
api.bootstrap(context='cli')
api.finalize()
api.Backend.xmlclient.connect()
inventory = {}
hostvars={}
meta={}
result =api.Command.hostgroup_find()['result']
for hostgroup in result:
inventory[hostgroup['cn'][0]] = { 'hosts': [host for host in hostgroup['member_host']]}
for host in hostgroup['member_host']:
hostvars[host] = {}
inventory['_meta'] = {'hostvars': hostvars}
inv_string = json.dumps( inventory)
print inv_string

0 comments on commit c930ee4

Please sign in to comment.