This repo focuses on the basic interactions between CVP and Ansible using the Arista AVD/CVP Collections. It allows the user flexibility in managing device configurations with CVP and Ansible. Configlets make up a device's full configuration. You can manage the configlets inside of CVP or generate them dynamically with Ansible and merge them inside of CVP.
- Python 3 & Ansible 2.9+
- Clone Arista AVD and CVP collections (instructions below)
- Update
ansible.cfg
with collections_path
Use a Docker Container with all necessary modules installed. Consider building a docker image and container from the instructions found here: https://github.com/mthiel117/dockerbuild.
Once the image is built run the container and attach it a volume to local directory and location of Arista collections. Sample Docker Run below. Turn this into a alias for simple launching.
docker run -it --rm -v $(PWD):/projects -v ~/git_projects/arista-ansible:/collections mycentosbox/base
# Create a directory for collections
mkdir collections
cd collections
# Clone Arista AVD & CVP collections
git clone https://github.com/aristanetworks/ansible-avd.git
git clone https://github.com/aristanetworks/ansible-cvp.git
Update ansible.cfg
with the path to the Arista AVD & CVP collections
[defaults]
collections_paths = /collections/ansible-cvp:/collections/ansible-avd/
There are a few files that need to be updated to provide data input for the playbooks.
inventory.yml
- Update CVP host with ip or fqdn of your CVP systemdatafiles/svis.yml
- Dictionary for SVI's to be applied to Devicesdatafiles/devices.csv
- List of Devices (CSV format) used to create base configletsgroup_vars/CVP_SERVERS/authconnection.yml
- CVP login and password and connection infogroup_vars/CVP_SERVERS/containers.yml
- Dictionary of Container Topologygroup_vars/CVP_SERVERS/devices.yml
- Dictionary of Devices, Containers, Configlets
There are 2 main playbooks that we will focus on.
-
playbooks/generate_configs.yml
- Generates Base configlets for each device and Common SVIs -
playbooks/update_cvp.yml
- Updates Continer Topology & Uploads configlets into CVP and attaches them to the appropriate device and/or container. Tags (upload,update,full
) are used to control which tasks are executed in playbookupload
tag will execute task to upload configlet to CVPupdate
tag will execute tasks to move devices, attach configlets and create container topologyfull
tag will execute all tasks above
# Generate Configs
ansible-playbook playbooks/generate_configs.yml
# Upload Configlets
ansible-playbook playbooks/update_cvp.yml --tags upload
# Update Device configlets and Container Topology
ansible-playbook playbooks/update_cvp.yml --tags update
# Do Everything: Upload Configlets and Update Device configlets and Container Topology
ansible-playbook playbooks/update_cvp.yml --tags full