Skip to content

Commit

Permalink
Use hostgroup_find(all=True) returns member hosts of all hostgroups i…
Browse files Browse the repository at this point in the history
…n a single call (ansible#29106)
  • Loading branch information
rgroten authored and ansibot committed Dec 18, 2017
1 parent 2cdbde5 commit b34d150
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions contrib/inventory/freeipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import argparse
from ipalib import api
import json
from distutils.version import StrictVersion


def initialize():
Expand Down Expand Up @@ -35,15 +34,11 @@ def list_groups(api):
inventory = {}
hostvars = {}

ipa_version = api.Command.env()['result']['version']
result = api.Command.hostgroup_find()['result']
result = api.Command.hostgroup_find(all=True)['result']

for hostgroup in result:
# Get direct and indirect members (nested hostgroups) of hostgroup
members = []
if StrictVersion(ipa_version) >= StrictVersion('4.0.0'):
hostgroup_name = hostgroup['cn'][0]
hostgroup = api.Command.hostgroup_show(hostgroup_name)['result']

if 'member_host' in hostgroup:
members = [host for host in hostgroup['member_host']]
Expand Down

0 comments on commit b34d150

Please sign in to comment.