Note
This plugin is part of the community.zabbix collection (version 1.5.0).
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
.
To use it in a playbook, specify: community.zabbix.zabbix_inventory
.
New in version 1.4.0: of community.zabbix
The below requirements are needed on the local controller node that executes this inventory.
Parameter | Choices/Defaults | Configuration | Comments | |
---|---|---|---|---|
add_zabbix_groups boolean |
| If set to True, hosts will be added to groups based on their zabbix groups | ||
cache boolean |
| ini entries: [inventory] env:ANSIBLE_INVENTORY_CACHE | Toggle to enable/disable the caching of the inventory's source data, requires a cache plugin setup to work. | |
cache_connection string | ini entries: [defaults] [inventory] env:ANSIBLE_CACHE_PLUGIN_CONNECTION env:ANSIBLE_INVENTORY_CACHE_CONNECTION | Cache connection data or path, read cache plugin documentation for specifics. | ||
cache_plugin string | Default: "memory" | ini entries: [defaults] [inventory] env:ANSIBLE_CACHE_PLUGIN env:ANSIBLE_INVENTORY_CACHE_PLUGIN | Cache plugin to use for the inventory's source data. | |
cache_prefix string | Default: "ansible_inventory_" | ini entries: [default] [inventory] env:ANSIBLE_CACHE_PLUGIN_PREFIX env:ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX | Prefix to use for cache plugin files/tables | |
cache_timeout integer | Default: 3600 | ini entries: [defaults] [inventory] env:ANSIBLE_CACHE_PLUGIN_TIMEOUT env:ANSIBLE_INVENTORY_CACHE_TIMEOUT | Cache duration in seconds | |
compose dictionary | Default: {} | Create vars from jinja2 expressions. | ||
groups dictionary | Default: {} | Add hosts to group based on Jinja2 conditionals. | ||
host_zapi_query dictionary | Default: {} | API query for hosts - see zabbix documentation for more details https://www.zabbix.com/documentation/current/manual/api/reference/host/get
| ||
selectApplications string | 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 | |||
selectDashboards string | 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 | |||
selectDiscoveries string | 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 | |||
selectDiscoveryRule string | 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 | |||
selectGraphs string | 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 | |||
selectGroups string | 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 | |||
selectHostDiscovery string | 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 | |||
selectHttpTests string | 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 | |||
selectInheritedTags string | 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 | |||
selectInterfaces string | 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 | |||
selectInventory string | 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 | |||
selectItems string | 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 | |||
selectMacros string | 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 | |||
selectParentTemplates string | 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 | |||
selectTags string | 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 | |||
selectTriggers string | 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 | |||
http_login_password string | Basic Auth password | |||
http_login_user string | Basic Auth login | |||
keyed_groups list / elements=string | Default: [] | Add hosts to group based on the values of a variable. | ||
leading_separator boolean added in 2.11 of ansible.builtin |
| 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. | ||
login_password string / required | env:ZABBIX_PASSWORD | Zabbix user password. | ||
login_user string / required | env:ZABBIX_USERNAME | Zabbix user name. | ||
proxy string | Default: "" | Proxy server to use for reaching zabbix API | ||
server_url string / required | env:ZABBIX_SERVER | URL of Zabbix server, with protocol (http or https). url is an alias for server_url .aliases: url | ||
strict boolean |
| If yes make invalid entries a fatal error, otherwise skip and continue.Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. | ||
timeout integer | Default: 10 | The timeout of API request (seconds). | ||
use_extra_vars boolean added in 2.11 of ansible.builtin |
| ini entries: [inventory_plugins] env:ANSIBLE_INVENTORY_USE_EXTRA_VARS | Merge extra vars into the available variables for composition (highest precedence). | |
validate_certs boolean |
| env:ZABBIX_VALIDATE_CERTS | If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates. |
# 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")
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/zabbix/zabbix_inventory_inventory.html