---
title: "API integration with Ansible and Zabbix"
id: "13453"
type: "post"
slug: "api-integration-with-ansible-and-zabbix"
published_at: "2020-03-20T15:02:21+00:00"
modified_at: "2020-03-20T15:02:21+00:00"
url: "https://ipfabric.io/blog/api-integration-with-ansible-and-zabbix/"
markdown_url: "https://ipfabric.io/blog/api-integration-with-ansible-and-zabbix.md"
excerpt: "Great example of the IP Fabric's API integration with Ansible and Zabbix, together with practical examples and the code snippets."
taxonomy_category:
  - "Integrations"
taxonomy_post_tag:
  - "Zabbix"
---

# API integration with Ansible and Zabbix

Great example of the IP Fabric's API integration with Ansible and Zabbix, together with practical examples and the code snippets.

[https://ipfabric.io/author/milan-zapletal/](https://ipfabric.io/author/milan-zapletal/)
[Milan Zapletal](https://ipfabric.io/author/milan-zapletal/)
Solution Architect

Published

20 Mar 2020

Updated

20 Mar 2020

The IP Fabric platform provides a standard Application Programming Interface (API), and this interface allows to integrate IP Fabric platform with any 3rd party software or build any custom scripts. See the [official documentation](https://docs.ipfabric.io/api/)
 for details on how to use our API.

Thanks to a [unique discovery algorithm](https://ipfabric.io/product/network-discovery/)
, **IP Fabric is capable of collecting data about all active network devices automatically**. It collects more than 1000 parameters from each individual device and provides the data in a standardized form. Those **data can be viewed in GUI or accessed via API**. Hence all available data serves as a perfect baseline for any automation or API integration efforts.

## The goal of this article

This article demonstrates how to add devices to Zabbix monitoring software. Zabbix uses the SNMP protocol for monitoring; therefore, we have to check if a device has SNMP configured and if no, then we will configure it automatically using the Ansible tool.

## Where to get API information in IP Fabric

The IP Fabric is a very flexible tool when it comes to getting information. The same applies to well-documented API fetch points. In every technology table, including the main device inventory, there’s table description, that appears on request.

API Integration: URL for device inventory

The full device inventory can be accessed with a POST request to `https://ipfabric.domain.com/api/v1/tables/inventory/devices`. The response can be filtered by any column.

So let’s say that we want to get all Cisco IOS, IOS-XE devices, the following code snippet will accomplish just that:

```
curl -k -s https://ipfabric.domain.com/api/v1/tables/inventory/devices \
   -u 'username:password' \
   -H 'Content-Type: application/json' \
   --data-binary '{"columns":["sn","hostname","loginIp","loginType"],"filters":{"or":[{"family":["eq", "ios"]},{"vendor":["eq","ios-xe"]}]},"snapshot":"$last"}'
```

## Access the SNMP data from the IP Fabric

All data related to SNMP configuration for all discovered devices is presented in a different technology table related to SNMP. If in doubt, there’s always the search box that will help with finding a specific target. Let’s say we are looking for SNMP information, let’s just type ‘SNMP’ and see results. The platform will provide us with information about tables, including SNMP information. We will navigate to SNMP Summary, where we again collect API link.

In the same way, we collected full device inventory, filtering IOS and IOS-XE, we can collect all devices with that has no SNMP community configured.

```
curl -k -s  https://ipfabric.domain.com/api/v1/tables/management/snmp/summary \
     -u 'username:password' \
     -H 'Content-Type: application/json' \
     --data-binary '{"columns":["id"],"filters":{"communitiesCount":["eq",0],"sn":["eq","'"$sn"'"]},"snapshot":"$last"}'
```

By comparing **Inventory with IOS or IOS-XE** devices and **SNMP summary table** information, where we can find devices with no configured SNMP community, we will get the full list of devices that need to be added to Zabbix and configured with Ansible.

The entire bash script can [be seen in our public repository.](https://github.com/ipfabric/integration-examples/blob/master/snmp-ansible-zabbix/snmpAutoConf.sh)

## Ansible automation

Ansible is an open-source configuration management and application-deployment tool. It helps to automate configuration updates with templates called the ‘playbooks’ with various network vendors, including servers.

We used the **Ansible version 2.5.1.** Our simple Ansible playbook will add a new SNMP community and trap the host server as well.

Please note, that you may want to modify the YAML file to fit your environment, we only **used ‘dummy’ SNMP server IP**, which may be the Zabbix IP address and **SNMP community** as an example. The following snippet may need an update per case.

```
     - name: Add SNMP config
      ios_config:
        lines:
        - snmp-server community newCommunity ro
        - snmp-server host 10.10.10.10 version 2c snmpCommunity
      notify:
      - Save Configuration 
```

The entire Yaml file can [be seen in our public repository.](https://github.com/ipfabric/integration-examples/blob/master/snmp-ansible-zabbix/snmp-config.yml)

## Zabbix automation

The Zabbix configuration is updated with the help of powerful [Zabbix-CLI](https://github.com/unioslo/zabbix-cli)
, which was originally developed by members of the Department for IT Infrastructure at [the Center for Information Technology](https://www.usit.uio.no/)
 at [the University of Oslo, Norway](https://www.uio.no/)
. It’s a very user-friendly and powerful solution for connecting to Zabbix’s API.

The connector needs to be preinstalled and configured accordingly. For the full installation process, please, follow [the documentation](https://github.com/ipfabric/integration-examples/tree/master/snmp-ansible-zabbix)
.

Thank you for reading!

If you have found this article helpful, please follow our company’s [LinkedIn](https://www.linkedin.com/company/ip-fabric/)
or [Blog](https://blog.ipfabric.io/)
, where there will be more content emerging.

## Related Resources

Integrations

### [4 Steps To Map Application Dependencies To Critical Infrastructure](https://ipfabric.io/blog/map-application-dependencies-in-4-steps/)

Use IP Fabric's application infrastructure mapping capabilities to trace application dependencies across network, cloud, and host-level infrastructure.

Integrations

### [Application To Infrastructure Mapping 101](https://ipfabric.io/blog/application-to-infrastructure-mapping/)

Protect critical applications across on-prem and cloud environments using IP Fabric's new application-to-infrastructure mapping capabilities.

Integrations

### [IP Fabric Partners With Illumio to Unify Cloud, Network, and Application Visibility](https://ipfabric.io/blog/illumio-partnership-network-application-visibility/)

This industry-first collaboration will help customers to correlate application and workload context with a digital twin of cloud and network behavior.
