A python script that queries a mysql database and creates an Ansible inventory based on the output
For more information on developing a custom inventory script, please refer the Ansible documentation
Script accepts --hots <hostname>
and --list
arguments as per the requirements
A sample schema dump is also provided in the cmdb.sql
file
To use in Ansible Tower:
- Create a custom credential type using the definition in the
mysql_cmdb_custom_credential_type_definition
file - Define the actual crednetial for the mydql db
- In Ansible tower, Create a new custom inventory script source under resources using the contents of the
inventory_custom_cmdb.py
file
Note: The script requires the python mysql-connector
package, so make sure that the library is installed in one of the python virtual environments on all the tower nodes.
- Create a new inventory
- Create a new source under the new inventory that used the type
Custom Script
and reference the source created in step 3
Note: Make sure to use the correct Ansible Environment with the correct python prerequisites installed