Utilities scripts for itop, an open source cmdb.
Empowers CMDB by connectincg to other system like Ansible.
This script pulls info from an ITOP cmdb to generate a JSON hosts list to be used as a Dynamic Inventory Source for ansible commands. This is very useful to perform operations on groups of hosts, according to your physical, logical or network infrastructure, or according your services, as it is defined on your cmdb.
For example, you can send commands to all machines of a given rack, or those plugged to a specific network device, or those having related open tickets. You have to define a set of hosts by using an OQL select statement.
As a prerequisite, you need an iTop instance, and an Ansible instance too, in the same or in different servers. Just copy the script to your ansible machine, in /etc/ansible, and made it executable.
cd /etc/ansible
wget --no-check-certificate https://github.com/jaimevalero78/itop-utilities/raw/master/FromITOPtoAnsible.sh
chmod +x /etc/ansible/FromITOPtoAnsible.sh
Also, you have to change the credentials for the itop instance in the script. The parameters you should change are:
# Parameters: Change this according to your itop credentials
MY_USER=replace_for_your_itop_user
MY_PASS=replace_for_your_itop_password
ITOP_SERVER=replace_for_your_itop_server
INSTALLATION_DIRECTORY=itop-itsm
HTTPS=Y
Passed as enviroment variable
- OQL = Sentence in OQL
- FIELD = (optional) name of the field to be used as hostname
Perform a ping against all HP Server against the itop demo instance. http://goo.gl/FrOQdQ
cd /etc/ansible
export OQL="SELECT Server WHERE brand_name = 'HP'"
ansible all -i FromITOPtoAnsible.sh -m shell -m "ping"
# The above command would try to access each of the server list : { "hosts" : [ "Server1" , "Server3" , "Server4" , "SRV1" , "SRV1" , "Web" ] }
# and try to login against it.
# It will fail, of course. You have to configure the script to query your own itop and ansible instances!