Using Zabbix Inventory Script for AWX Ansible Tower 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
- Ansible Tower or AWX Ansible Tower
- Zabbix Server
- 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
Then update self
value and save INVENTORY SCRIPT as follow:
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
|
Step2, Create NEW
INVENTORY from Tower/Inventories/Create a new inventory/Invnetory/ and Saved
it.
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.
Later Start sync
process to fetch Zabbix Host and Host group configuration as Inventory.
If cloud icon turn
green, can use this inventory source from zabbix to your templates and
workflows.
Thank You! J
Comments
Post a Comment