tree: 0dfbd67369edc07cdcb4db7ee55a8fd6b06af0dc [path history] [tgz]
  1. README.md
  2. TO.py
infrastructure/ansible/dynamic.inventory/README.md

Ansible Dynamic Inventory

This python script uses the Traffic Ops Python Native Client to expose much of the TO dataset as an ansible inventory on demand as Ansible patterns.

Requirements

You will need to ensure the Traffic Ops Python Native Client is available to the python env shared by Ansible (https://github.com/apache/trafficcontrol/tree/master/traffic_control/clients/python).

Due to limitations in the way parameters are passed in Ansible Dynamic Inventory scripts, the following environment variables must be defined:

export TO_USER=<my.to.username>
export TO_PASSWORD=<my.to.password>
export TO_URL=<functional TrafficOps server fqdn or IP>

Failure to set login credentials will result in a valid, but empty response.

If you find yourself debugging this or are curious what's available, the following commands are handy:

ansible-inventory -i infrastructure/ansible/dynamic.inventory/TO.py --graph --vars > ansible.inventory.txt
python infrastructure/ansible/dynamic.inventory/TO.py --list --username "<my.to.username>" --username "<my.to.password>" --url "to.kabletown.invalid" --verify_cert true

Example Usage

Use ansible ad-hoc to test connectivity to all offline edge caches belonging to the Kabletown2.0 CDN and having “den” in the fqdn somewhere, but not with “aurora” in their fqdn.

ansible -i infrastructure/ansible/dynamic.inventory/TO.py 'server_status|OFFLINE:&server_type|EDGE:&server_cdnName|Kabletown2.0:&*den*:!*aurora*' -m ping