/cldemo-dynamic-ansible-inventory

[DEPRECATED] Cumulus Networks Demo of Ansible dynamic inventory using Redis and a SQL database

Primary LanguagePython

DEPRECATED

This repo is no longer maintained.
For a list of current demos, please visit:
https://gitlab.com/cumulus-consulting/goldenturtle/


cldemo-dynamic-ansible-inventory

This demo shows how an external datasource can be used to populate all variable and host information at runtime.

There are two examples within this demo, one utilizes a redis datastore as the external source, the other utilizes SQLite as an external SQL database.

This demo is built using the Cumulus Networks reference topology

Cumulus Reference Topology

Quickstart

Details

Once this repo has been cloned to the out of band management server you can build one or both of the databases.

Once either database is installed and populated with data (which is done as part of the install playbook),

##Demo Redis First, install the redis database with ansible-playbook redis_setup.yml. This step will also populate the redis database with the network variables. Next, you can test without a provided inventory and see that Ansible fails. This command is ansible all -m ping To test by pulling the host information out of Redis use ansible all -m ping -i get_redis_inventory.py. Once the ping is successful, you can configure the network with ansible-playbook provision_network.yml -i get_redis_inventory.py

Note: If the Redis demo was previously run, please reset the lab with ansible-playbook reset.yml -i get_redis_inventory.py

You can verify that the network was provisioned correctly with ansible spine01 -a 'vtysh -c "show ip bgp sum"' -i get_redis_inventory.py --become. 2 BGP peers should appear.

##Demo SQL First, install the SQLite database with ansible-playbook sql_setup.yml. This step will also populate the SQL database with the network variables. When the database is created, SQLite will create a file in the current directory called "ansible_db.sqlite".

Note: This demo will fail if ansible_db.sqlite is not in the same directory that the ansible commands are being executed from.

Next, we can test a ping without a provided inventory file with ansible all -m ping.

Now, providing an inventory, we can test the ping again using ansible all -m ping -i get_sql_inventory.py, which will work.

Finally, the network can be configured with ansible-playbook provision_network.yml -i get_sql_inventory.py.

Note: If the Redis demo was previously run, please reset the lab with ansible-playbook reset.yml -i get_sql_inventory.py

You can verify that the network was provisioned correctly with ansible spine01 -a 'vtysh -c "show ip bgp sum"' -i get_sql_inventory.py --become. 2 BGP peers should appear.