diff --git a/devel-utils/docker-compose.yml b/devel-utils/docker-compose.yml index 5fac7be..39459ee 100644 --- a/devel-utils/docker-compose.yml +++ b/devel-utils/docker-compose.yml @@ -8,7 +8,7 @@ services: init-guac-db: image: guacamole/guacamole:latest user: root - command: ["/bin/sh", "-c", "test -e /init/initdb.sql && echo 'init file already exists' || /opt/guacamole/bin/initdb.sh --postgres > /init/initdb.sql" ] + command: ["/bin/sh", "-c", "test -e /init/initdb.sql && echo 'init file already exists' || /opt/guacamole/bin/initdb.sh --postgresql > /init/initdb.sql" ] volumes: - dbinit:/init diff --git a/plugins/inventory/README.md b/plugins/inventory/README.md index 705137e..f618da2 100644 --- a/plugins/inventory/README.md +++ b/plugins/inventory/README.md @@ -1,6 +1,6 @@ # scicore.guacamole.guacamole_inventory – Apache Guacamole dynamic inventory plugin -Wait would you say about getting all your connections details from Apache Guacamole and parsing them to ansible as inventory ? It would be amazing, right ? +What would you say about getting all your connections details from Apache Guacamole and passing them to Ansible as inventory ? It would be amazing, right ? Guess what, You are in the right place. It's all about this plugin. @@ -15,7 +15,7 @@ Guess what, You are in the right place. It's all about this plugin. ## Synopsis -- Get connection details from Apache Guacamole API and parse them to ansible as inventory. +- Get connection details from Apache Guacamole API and pass them to ansible as inventory. - Uses an YAML configuration file ending with either `guacamole.yml` or `guacamole.yaml` to set parameter values. ## Requirements diff --git a/plugins/module_utils/guacamole.py b/plugins/module_utils/guacamole.py index 0845ee6..e582303 100644 --- a/plugins/module_utils/guacamole.py +++ b/plugins/module_utils/guacamole.py @@ -81,13 +81,15 @@ def guacamole_get_connections(base_url, validate_certs, datasource, group, auth_ all_connections = [] - if 'childConnections' in connections_group: - all_connections = connections_group['childConnections'] - - if 'childConnectionGroups' in connections_group: - for group in connections_group['childConnectionGroups']: - if 'childConnections' in group: - all_connections = all_connections + group['childConnections'] + def fetch_child_connections(a_connections_group, depth=0): + for connection in a_connections_group: + all_connections.extend(connection.get('childConnections',[])) + if connection.get('childConnectionGroups') is not None: + fetch_child_connections(connection.get('childConnectionGroups'), depth = depth + 1) + if depth == 0: + return + + fetch_child_connections([connections_group]) return all_connections