Ansible Inventory Generator
Overview
Tool for the automated generation of Ansible inventory files by pulling data extracted from the WFO API.
Features
- Generate Ansible inventory from WFO API.
- Save processed data to appropriate inventory file(s).
- Ensure no alteration to existing inventory files in case of process failure.
Installation
Install from PIP.
pip install \
--pre \
--extra-index-url https://artifactory.software.geant.org/artifactory/api/pypi/geant-swd-pypi/simple \
ansible-inventory-generator
Deployment
Fill in environment variables and run the command to generate the Ansible inventory from the API.
# Rewritting environment variables
## URL of the WFO API (change IP only)
export aig_api_url=http://127.0.0.1:8080/api/v1/subscriptions/routers
## Token provided by each GSO instance admin (varies per environment)
export aig_gso_api_key=<fill_with_gso_token>
## Full paths where AIG will save host_vars
export aig_ansible_inventory_path=/path/to/base/host_vars/dir
# Execution of the command to generate the Ansible inventory files
ansible_inventory_generator
Ansible inventory files will be available under the path stated under hosts_file_dir
.
Troubleshooting
Issues when installing the PIP package
When experiencing an error like the following, switch to the user that has permissions over /usr/local/bin
:
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/ansible_inventory_generator'
If facing an error like the following, it may suggest a compatibility issue (maybe with the version of setuptools, wheels or pip):
AttributeError: install_layout. Did you mean: 'install_platlib'?
To try to address it, run the following:
pip install -U pip setuptools wheel
ansible_inventory_generator
command
403 error when running the This tool cannot reach the GSO API because it is authenticated. Use a correct aig_gso_api_key environment variable.