AVD container with Ansible AVD and CVP collections installed
287
AVD container with Ansible AVD and Ansible AVD collections installed
Breaking change in avd3.3.3_cvp3.3.1_debian and later
/home/avd/.ansible/collections/ansible_collections will be used to install collections in the container.collections_paths must be default and must NOT be set explicitly in the ansible.cfgavd-all-in-one is a close replica of avd-base container. The major difference is that Ansible AVD and Ansible CVP collections are pre-installed and container is ready to use.
For details, check avd-base container documentation. This readme only includes essential how-to instructions to avoid double maintenance.
ansible.cfg in AVD inventory repository must have following settings for avd-all-in-one container to work correctly: collections_paths = /home/avd/ansible-cvp:/home/avd/ansible-avd:/home/avd/.ansible/collections/ansible_collections
If you have to override that for development purposes, mount ansible-avd or ansible-cvp repositories from your machine to /home/avd/ansible-cvp or /home/avd/ansible-avd manually or using similar settings in vscode.json:
"mounts": [
"source=${localWorkspaceFolder}/../ansible-avd,target=/home/avd/ansible-avd,type=bind,consistency=cached,readonly=true"
],
ansible.cfg in AVD inventory repository must use the default collection path. collections_paths must NOT be set explicitly.
If you have to override that for development purposes, mount ansible-avd or ansible-cvp repositories from your machine to /home/avd/.ansible/collections/ansible_collections/arista/avd and /home/avd/.ansible/collections/ansible_collections/arista/cvp
"mounts": [
"source=${localWorkspaceFolder}/../ansible-avd,target=/home/avd/.ansible/collections/ansible_collections/arista/avd,type=bind,consistency=cached,readonly=true"
],
In case of concerns, check your ansible environment with ansible-galaxy collection list.
Execute following command to run the avd-all-in-one container manually:
docker run --rm -it -v $(pwd):/home/avd/projects/ avdteam/avd-all-in-one
Type exit to leave the container environment.
Create .devcontainer directory in your AVD inventory repository. Create devcontainer.json inside this directory.
Use following devcontainer.json to start:
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/python-3
{
"name": "AVD",
"image": "avdteam/avd-all-in-one:latest",
// Set *default* container specific settings.json values on container create.
"settings": {
"python.testing.pytestPath": "/root/.local/bin/pytest",
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"vscoss.vscode-ansible",
"timonwong.ansible-autocomplete",
"codezombiech.gitignore",
"tuxtina.json2yaml",
"jebbs.markdown-extended",
"donjayamanne.python-extension-pack",
"njpwerner.autodocstring",
"quicktype.quicktype",
"jack89ita.copy-filename",
"mhutchie.git-graph",
"eamodio.gitlens",
"yzhang.markdown-all-in-one",
"davidanson.vscode-markdownlint",
"christian-kohler.path-intellisense",
"ms-python.vscode-pylance",
"tht13.python"
],
"containerEnv": {
"ANSIBLE_CONFIG": "./ansible.cfg"
},
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "avd"
}
Unfortunately devcontainer.json is not yet supported with VScode Remote-SSH plugin. You can track recent development here.
The easiest way to use avd-all-in-one container with remote SSH is creating a simple alias: alias avd="sudo docker run --rm -it -v $(pwd):/home/avd/projects/ avdteam/avd-all-in-one"
k8s-avd-cvp.yml is an example pod definition for running avd-all-in-one on CloudVision (CentOS), however it should work on other linux distributions (the CVP env vars won't be needed in that case).
The below example is for running the pod on one specific node (set by the nodeName: $PRIMARY_HOSTNAME node selection in the spec)
docker pull avdteam/avd-all-in-onegroupadd -g 1000 avd && useradd avd -u 1000 -g 1000/home/avdenvsubst < /cvpi/conf/kubernetes/avd.yml | kubectl apply -f -Note that the pod can be also deployed on any node by removing the
nodeNamefield from the spec, however that would also require pulling the image onto all nodes and synchronozing the project files between all nodes.
-v ${pwd}/:/home/avd/projects in docker run command may not work as expected in MacOS or some Linux distributions. Use -v $(pwd)/:/home/avd/projects instead.
On a Linux system incorrect permissions set on an AVD inventory repository can break execution of Ansible commands inside the AVD container.
Content type
Image
Digest
sha256:ecc70fe1d…
Size
300.7 MB
Last updated
over 3 years ago
docker pull juliopdx/avd-dev