项目作者: avinash6784

项目描述 :
Ansible dynamic inventory for MySQL with Python Script
高级语言: Python
项目地址: git://github.com/avinash6784/ansible-dynamic-inventory-mysql.git


Ansible dynamic inventory for MySQL with Python Script - ansible-dynamic-inventory-mysql

Ansible dynamic inventory for MySQL with Python Script. Here I have created test dynamic inventory script with python to get data from MySQL and Ansible will use it as an inventory source as long as it returns a JSON structure with the —list option.

Usage

Simply call the script like the following

  1. ansible-playbook -i dynamic_inventory.py example_playbook.yml
  2. # or
  3. ansible -i dynamic_inventory.py group_name -m ping

Python script run and its sample json output

  1. ./dynamic_inventory.py --list
  2. output ---
  3. {
  4. "all": ["localdb", "local", "localhost"],
  5. "REDHAT": ["local", "localhost"],
  6. "WINDOWS": ["localdb"],
  7. "app": ["localhost"],
  8. "db": ["localdb", "local", "localhost"]
  9. }

Author Informations

This python script was created by Avinash Pawar.