mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update dynamic inventory zabbix.py (#19862)
Added _meta to improve the speed when using this dynamic inventory file
This commit is contained in:
parent
61b18cc355
commit
955f8923e7
1 changed files with 9 additions and 3 deletions
|
@ -24,10 +24,12 @@ Zabbix Server external inventory script.
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
Returns hosts and hostgroups from Zabbix Server.
|
Returns hosts and hostgroups from Zabbix Server.
|
||||||
|
If you want to run with --limit against a host group with space in the
|
||||||
|
name, use asterisk. For example --limit="Linux*servers".
|
||||||
|
|
||||||
Configuration is read from `zabbix.ini`.
|
Configuration is read from `zabbix.ini`.
|
||||||
|
|
||||||
Tested with Zabbix Server 2.0.6.
|
Tested with Zabbix Server 2.0.6 and 3.2.3.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
@ -102,6 +104,9 @@ class ZabbixInventory(object):
|
||||||
|
|
||||||
data[groupname]['hosts'].append(hostname)
|
data[groupname]['hosts'].append(hostname)
|
||||||
|
|
||||||
|
# Prevents Ansible from calling this script for each server with --host
|
||||||
|
data['_meta'] = { 'hostvars': self.meta }
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -110,6 +115,7 @@ class ZabbixInventory(object):
|
||||||
self.zabbix_server = None
|
self.zabbix_server = None
|
||||||
self.zabbix_username = None
|
self.zabbix_username = None
|
||||||
self.zabbix_password = None
|
self.zabbix_password = None
|
||||||
|
self.meta = {}
|
||||||
|
|
||||||
self.read_settings()
|
self.read_settings()
|
||||||
self.read_cli()
|
self.read_cli()
|
||||||
|
|
Loading…
Reference in a new issue