From c7e57403f928e1772903105e8e4e87fc49299c9f Mon Sep 17 00:00:00 2001 From: Alexandre Georges Date: Fri, 6 Oct 2023 20:18:00 +0200 Subject: [PATCH] Fixing issue #1066 (#1098) --- plugins/inventory/zabbix_inventory.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/inventory/zabbix_inventory.py b/plugins/inventory/zabbix_inventory.py index 4aee5ef33..8e4be416b 100644 --- a/plugins/inventory/zabbix_inventory.py +++ b/plugins/inventory/zabbix_inventory.py @@ -1,8 +1,9 @@ # # Copyright: (c), Ansible Project # -# (c) 2013, Greg Buehler +# (c) 2023, Alexandre Georges # (c) 2018, Filippo Ferrazini +# (c) 2013, Greg Buehler # (c) 2021, Timothy Test # Modified from ServiceNow Inventory Plugin and Zabbix inventory Script # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -445,7 +446,16 @@ def parse(self, inventory, loader, path, # organize inventory by zabbix groups if self.get_option('add_zabbix_groups'): - content = self._zapi.host.get({'selectGroups': ['name']}) + + response = self.api_request( + 'host.get', + { + 'selectGroups': ['name'] + } + ) + res = json.load(response) + content = res['result'] + for record in content: host_name = record['host'] if len(record['groups']) >= 1: