From 29d23fa70d418e7823cf70bb72162b48e947d4b9 Mon Sep 17 00:00:00 2001 From: Alexandre Georges Date: Wed, 4 Oct 2023 12:00:51 +0200 Subject: [PATCH] Fixing issue #1066 --- 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: