Home Zabbix as AWX's Dynamic Inventory
Post
Cancel

Zabbix as AWX's Dynamic Inventory

Hello! Have a nice day.

Today I am going to show you how to use Zabbix Server as Inventory Source for Ansible AWX Tower. As you know Ansible Tower allow you to set not only static inventory but also dynamic inventory. Dynamic Inventories executable programs that collect information from some external source and output the inventory in JSON format. Now, I will use Zabbix Monitoring Server as my external source to fetch inventory. As prerequisites, we need

  1. Ansible Tower or AWX Ansible Tower
  2. Zabbix Server
  3. And need to install Zabbix-api module
    • Zabbix-api can download Here:
    • $pip install zabbix-api-version.tar.gz As first Step, we are going to fetch zabbix.py which is dynamic inventory script contributed for Ansible project. Copy and paste the script in TowerUI/Inventory Scripts/CREATE INVENTORY SCRIPT /CUSTOM SCRIPT

https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/zabbix.py

Window shadow

Then update self value and save INVENTORY SCRIPT as follow:

1
2
3
4
5
6
7
8
9
def __init__(self):

        self.defaultgroup = 'group_all'
        self.zabbix_server = 'http://zabbix_server_ip'
        self.zabbix_username = 'Admin'
        self.zabbix_password = 'Admin_Password'
        self.validate_certs = True
        self.read_host_inventory = False
        self.use_host_interface = True

Create NEW INVENTORY from Tower/Inventories/Create a new inventory/Invnetory/ and Saved it.

Window shadow

I created new source via SOURCE tab. SOURCE value can choose other on-prem or cloud infrastructure management servers but this time I choose Custom Script.

Window shadow

Later Start sync process to fetch Zabbix Host and Host group configuration as Inventory.

Window shadow

If cloud icon turn green, can use this inventory source from zabbix to your templates and workflows.

Window shadow

This post is licensed under CC BY 4.0 by the author.

Gmail API

101 Systemd