Setup Ansible AVD With VS Code Container¶
Arista AVD provides an easy way to set up a lab or demo environment using a pre-configured VScode container with a web interface to connect and edit files.
We can leverage this container in different ways like a demo, remote lab, training sessions, or development solution. However, on this page, we will focus only on how to play with AVD demo content.
VScode container overview¶
This container comes with a set of options available to let you customize your environment:
AVD_MODE: If set to
demo, container will install AVD content to test it from
get.avd.sh. (Supported mode:
AVD_PASSWORD: Allow user to set a password for VScode authentication. If not set, access isn’t protected by any password.
AVD_GIT_USER: Username to configure in
AVD_GIT_EMAIL: Email to configure in
AVD_USER_EXTENSIONS_FILE: Allow user to install additional VScode extensions.
AVD_USER_REPOS: Path to a text file in your container with a list of repository to clone (one repository per line).
AVD_USER_SCRIPT: Path to a shell script to execute during entrypoint execution.
These settings must be used to mount and edit file from your physical host.
AVD_UID: Set uid for AVD user in container.
AVD_GID: Set gid for AVD user in container.
The container also comes with Docker installed, and in case you want to run Docker from your container, you can expose your local Docker socket from your host to your container:
To run this container, few requirements are expected:
- Docker installed on a host: laptop, VM, server, or anything that runs Docker
- Git configured with at least username and email
Get AVD demo in VSCode¶
We will ask the container to install the following content in your container automatically:
- Ansible Arista Validated Design collection using Git (devel) version.
- Ansible Arista CloudVision collection using Git (devel) version.
- AVD with CloudVision demo repository
The container will listen on port
8080, but we can be change it accordingly by using Docker CLI
In this setup, the container will be destroyed after you stop it. Since we don’t share any volumes, all changes will be lost.
Once your container is started, confirm with the following Docker command:
You should be able to connect to your VSCode instance using your favorite browser with the following URL:
Customize your container¶
Once you run your first AVD demo, you may want to not use non-volatile storage or install your repositories.
Mount your local folder¶
The first option is to mount one of your local folders to save your work from your container. Considering your local folder is empty, you can add this line to your Docker CLI:
Complete CLI example below:
Install additional repositories¶
Now, you want to ship your own demo in your container with Git clone instead of local file sharing, you can leverage the following option:
And then your
my_repos.txt file should be like:
By default, Docker can’t load a file from your host. The path you provide in
AVD_USER_REPOS must be configured using a shared volume.
For more details and options, you can check our repository for this container: arista-netdevops-community/docker-avd-vscode