community.zabbix.zabbix_inventory inventory – Zabbix Inventory Plugin
Note
This inventory plugin is part of the community.zabbix collection (version 1.9.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.zabbix
.
You need further requirements to be able to use this inventory plugin,
see Requirements for details.
To use it in a playbook, specify: community.zabbix.zabbix_inventory
.
New in community.zabbix 1.4.0
Synopsis
Zabbix Inventory plugin
All vars from zabbix are prefixed with zbx_
Requirements
The below requirements are needed on the local controller node that executes this inventory.
python >= 2.6
zabbix-api >= 0.5.4
Parameters
Parameter |
Comments |
---|---|
If set to True, hosts will be added to groups based on their zabbix groups Choices:
|
|
Toggle to enable/disable the caching of the inventory’s source data, requires a cache plugin setup to work. Choices:
Configuration:
|
|
Cache connection data or path, read cache plugin documentation for specifics. Configuration:
|
|
Cache plugin to use for the inventory’s source data. Default: Configuration:
|
|
Prefix to use for cache plugin files/tables Default: Configuration:
|
|
Cache duration in seconds Default: Configuration:
|
|
Create vars from jinja2 expressions. Default: |
|
Add hosts to group based on Jinja2 conditionals. Default: |
|
API query for hosts - see zabbix documentation for more details https://www.zabbix.com/documentation/current/manual/api/reference/host/get Default: |
|
query Return an applications property with host applications. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/application/object for more details on field names |
|
query Return a dashboards property. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/templatedashboard/object for more details on field names |
|
query Return a discoveries property with host low-level discovery rules. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/discoveryrule/object for more details on field names |
|
query Return a discoveryRule property with the low-level discovery rule that created the host (from host prototype in VMware monitoring). To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] please see https://www.zabbix.com/documentation/current/manual/api/reference/discoveryrule/object for more details on field names |
|
query Return a discoveries property with host low-level discovery rules. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/graph/object for more details on field names |
|
query Return a groups property with host groups data that the host belongs to. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/hostgroup/object for more details on field names |
|
query Return a hostDiscovery property with host discovery object data. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/host/get for more details on field names |
|
query Return an httpTests property with host web scenarios. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/httptest/object for more details on field names |
|
query Return an inheritedTags property with tags that are on all templates which are linked to host. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/host/object#host_tag for more details on field names |
|
query Return an interfaces property with host interfaces. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/hostinterface/object for more details on field names |
|
query Return an inventory property with host inventory data. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/host/object#host_inventory for more details on field names |
|
query Return an items property with host items. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/item/object for more details on field names |
|
query Return a macros property with host macros. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/usermacro/object for more details on field names |
|
query Return a parentTemplates property with templates that the host is linked to To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/template/object for more details on field names |
|
query Return a tags property with host tags. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/host/object#host_tag for more details on field names |
|
query Return a triggers property with host triggers. To return all values specify ‘extend’ Can be limited to different fields for example setting the vaule to [‘name’] will only return the name Additional fields can be specified by comma seperated value [‘name’, ‘field2’] Please see https://www.zabbix.com/documentation/current/manual/api/reference/host/object#host_tag for more details on field names |
|
Basic Auth password |
|
Basic Auth login |
|
Add hosts to group based on the values of a variable. Default: |
|
The default value when the host variable’s value is an empty string. This option is mutually exclusive with |
|
The key from input dictionary used to generate groups |
|
parent group for keyed group |
|
A keyed group name will start with this prefix Default: |
|
separator used to build the keyed group name Default: |
|
Set this option to False to omit the This option is mutually exclusive with Choices:
|
|
Use in conjunction with keyed_groups. By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. This is because the default prefix is “” and the default separator is “_”. Set this option to False to omit the leading underscore (or other separator) if no prefix is given. If the group name is derived from a mapping the separator is still used to concatenate the items. To not use a separator in the group name at all, set the separator for the keyed group to an empty string instead. Choices:
|
|
Zabbix user password. Configuration:
|
|
Zabbix user name. Configuration:
|
|
Proxy server to use for reaching zabbix API Default: |
|
URL of Zabbix server, with protocol (http or https). Configuration:
|
|
If Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. Choices:
|
|
The timeout of API request (seconds). Default: |
|
Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
|
If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. Choices:
Configuration:
|
Examples
# Simple Inventory Plugin example
# This will create an inventory with details from zabbix such as applications name, applicaitonids, Parent Template Name, and group membership name
#It will also create 2 ansible inventory groups for enabled and disabled hosts in zabbix based on the status field.
plugin: community.zabbix.zabbix_inventory
server_url: https://zabbix.com
login_user: Admin
login_password: password
host_zapi_query:
selectApplications: ['name', 'applicationid']
selectParentTemplates: ['name']
selectGroups: ['name']
validate_certs: false
groups:
enabled: zbx_status == "0"
disabled: zbx_status == "1"
#Using Keyed Groups
plugin: community.zabbix.zabbix_inventory
server_url: https://zabbix.com
login_user: Admin
login_password: password
validate_certs: false
keyed_groups:
- key: zbx_status | lower
prefix: 'env'
- key: zbx_description | lower
prefix: 'test'
separator: ''
#Using proxy format of proxy is 'http://<user>:<pass>@<proxy>:<port>' or 'http://<proxy>:<port>'
plugin: community.zabbix.zabbix_inventory
server_url: https://zabbix.com
proxy: http://someproxy:8080
login_user: Admin
login_password: password
validate_certs: false
#Organize inventory groups based on zabbix host groups
plugin: community.zabbix.zabbix_inventory
server_url: https://zabbix.com
add_zabbix_groups: true
login_user: Admin
login_password: password
validate_certs: false
#Using compose to modify vars
plugin: community.zabbix.zabbix_inventory
server_url: https://zabbix.com
login_user: Admin
login_password: password
validate_certs: false
compose:
zbx_testvar: zbx_status.replace("1", "Disabled")