Aims to provide an inventory script for AWX/Tower as first target but also usable by vanilla Ansible with Consul catalog as data source.
Standalone Ansible inventory scripts can rely on INI configuration file where AWX/Tower rely only on environment variables. All data are pulled from the catalog API.
Simply add this script as inventory within AWX/Tower following the official documentation.
Following Working with dynamic inventory documentation, the simplest method to use this script as inventory is the implicit method:
wget https://raw.githubusercontent.com/wilfriedroset/consul-awx/master/consul_awx.py -o /etc/ansible/hosts
chmod +x /etc/ansible/hosts
# Configure it
cat << EOF > /etc/ansible/consul_awx.ini
[consul]
host: 127.0.0.1
port: 8500
scheme: http
verify: true
EOF
# Test it
/etc/ansible/hosts --list
This script was mostly inspired by consul_io.py