mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make FreeIPA inventory work (#25354)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
b900f4a3be
commit
c876f4f3cf
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
import argparse
|
||||
from ipalib import api
|
||||
import json
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
|
||||
def initialize():
|
||||
|
@ -31,13 +32,17 @@ def list_groups(api):
|
|||
|
||||
inventory = {}
|
||||
hostvars = {}
|
||||
meta = {}
|
||||
|
||||
ipa_version = api.Command.env()['result']['version']
|
||||
result = api.Command.hostgroup_find()['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']]
|
||||
if 'memberindirect_host' in hostgroup:
|
||||
|
|
Loading…
Reference in a new issue