Skip to content

AWX & Tower Integration

AVD & CVP Playbooks integration in AWX/Tower


This example shows how to deploy basic EVPN/VXLAN Fabric based on Arista Validated Design roles using Ansible Tower/AWX. This repository will be used as project on AWX and we will describe how to configure Tower for the following topics:

  • Create a project
  • Create inventory
  • Install collections
  • Install python requirements

All these elements are part of a dedicated demo repository available at arista-netdevops-community/avd-with-ansible-tower-awx

If you want to see how to build your inventory and all related variables, it is recommended to read following documentation:


To play with this repository, you need:

  • An AWX setup running on either Docker Compose or Kubernetes. All the commands for Python configuration will be done on docker-compose, but you can adapt for kubernetes.
  • Understanding of how to configure AVD in a pure Ansible CLI way.

Install Python requirements

Ansible CVP collection comes with a needs of additional libraries not part of a standard Python setup:

  • netaddr
  • Jinja2
  • treelib
  • cvprac
  • paramiko
  • jsonschema
  • requests
  • PyYAML
  • md-toc
Create virtual-environment

It is required to create virtual-env to not impact other workflow already deployed on your Tower setup.

# Docker status
tom@kube-tool:~$ docker ps
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                  NAMES
4a4627b21f93        ansible/awx:15.0.0   "/usr/bin/tini -- /u…"   8 days ago          Up 8 days           8052/tcp               awx_task
6ef41f162226        ansible/awx:15.0.0   "/usr/bin/tini -- /b…"   8 days ago          Up 8 days >8052/tcp   awx_web
a2fd85d0cc86        postgres:10          "docker-entrypoint.s…"   8 days ago          Up 8 days           5432/tcp               awx_postgres
573d03e33c44        redis                "docker-entrypoint.s…"   8 days ago          Up 8 days           6379/tcp               awx_redis

# Run shell in docker
tom@kube-tool:~$ docker exec -it awx_task bash

$ sudo pip3 install virtualenv
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Requirement already satisfied: virtualenv in /usr/local/lib/python3.6/site-packages

$ mkdir /opt/my-envs

$ chmod 0755 /opt/my-envs

$ cd /opt/my-envs/

$ python3 -m venv avd-venv

This configuration MUST be replicated on both container awx_task and awx_web

Instruct AWX to register our new Virtual Environment folder:

$ curl -X PATCH 'http://admin:password@<IP-of-AWX-INSTANCE>/api/v2/settings/system/' \
    -d '{"CUSTOM_VENV_PATHS": ["/opt/my-envs/"]}' -H 'Content-Type:application/json'

    "TOWER_URL_BASE": "",
    "LICENSE": {},
    "INSTALL_UUID": "f8a54d56-b1f3-4fdf-aa5b-9d6977d00eaa",
Provision virtual-environment

Before running playbook in a virtual-env, we have to install required libraries:

tom@kube-tool:~$ docker exec -it awx_task bash

# Activate virtual-env
$ cd /opt/my-envs/avd-venv
$ source bin/activate

# Install ansible AWX base lib
$ pip3 install psutil

# Install project requirements
$ curl -fsSL -o requirements.txt
$ pip3 install -r requirements.txt

From here, you have a clean python environment with all the expected requirements installed on your AWX runner.

Create AVD project on AWX

Create a project resource

First go to Resources > Projects and create a new one using:

  • SCM Type: Git
  • SCM Branch: master
  • Ansible Environment: /your/path/to/venv
  • SCM URL:

This project will be used for 2 things:

  • Get our inventory and all attached variables.
  • Get our playbooks to run in AWX.
Create Inventory resource

Next action is to create an inventory in AWX. It is a 2 step actions:

Create Inventory

Go to Resources > Inventory

Once ready, you need to add a source to your inventory

Add source

In your inventory, select Sources

Then add a source using your existing project

In our example, our inventory file is part of a subdirectory. So we had to type the path manually as it was not part of the suggestion list. Also, don’t forget to specificy virtual-env to use with this inventory.

Onc you click on Save button, select SYNC-ALL button to get all hosts part of your inventory:

You should get all your devices in Resources > Inventory > Your inventory Name

Now we can focus on playbook itself.

Create Playbook resource

Go to Resources > Templates.

In this section you have to provide at least:

  • Name of your Template: Build Fabric Configuration – no-deploy
  • Which inventory to use: EMEA Demo
  • Which project to use to get playbook: AVD Demo with CVP
  • Which playbook to use: playbooks/dc1-fabric-deploy-cvp.yml
  • Virtual Environment to use when running the playbook

As AVD implements Ansible TAGS, we have specified build only, but you can adapt to your own setup.

You can configure more than just one playbook, but we will focus on playbook definition as it is not an AWX user’s guide.

Update AVD playbook

How to install collection within project

Since AVD and CVP collection are not installed by default in AWX, you need to consider how to install them. You have 2 option: system wise or per project. Let’s consider per project as it is easier to upgrade

  • Create a folder named collections in your git project
  • Create a YAML file named requirements.yml with the following structure:
  - name: arista.avd
    version: 1.1.0
  - name: arista.cvp
    version: 2.1.0
What to change to work with AVD and AWX

Ansible has a default variable that point to inventory file used in playbook and named {{ inventory_file }}. Since AWX/Tower is using a database, this variable is not available anymore and inventory file does not exist in such environment.

AVD use this variable to read inventory and to build container topology on Cloudvision. So to mitigate this behavior, a small warkaround is to add a task that download your inventory from your git repository and define {{ inventory_file }}:

  • Define variable:
inventory_file: '/tmp/inventory.yml'
  • Update playbook
- name: Configuration deployment with CVP
  hosts: cv_server
  connection: local
  gather_facts: false
    - arista.avd
    - arista.cvp

    - name: Download Inventory file
      tags: [ build ]
        url: ''
        dest: '{{ inventory_file }}'
        mode: '0755'

    - name: run CVP provisioning
        name: arista.avd.eos_config_deploy_cvp
        container_root: 'DC1_FABRIC'
        configlets_prefix: 'DC1-AVD'
        device_filter: 'DC1'
        state: present

Run your playbook

Under Resources > Templates click on the rocket icon to start playbook execution

Last update: June 25, 2021