This is an example script for implementing dynamic inventory in Ansible. It could have been written in bash, but python is much easier to read.
- Copy inventory script to any path like
$HOME/test_inventroy.py
- Make file executable:
chmod +x $HOME/test_inventroy.py
- Change
store
to your needs. - Run
ansible -i $HOME/test_inventroy.py -m ping apache
oransible -i $HOME/test_inventroy.py -m ping all
- Enjoy!