Skip to content

Commit

Permalink
add avd single-l3ls dc example
Browse files Browse the repository at this point in the history
  • Loading branch information
ankudinov committed Jun 5, 2024
1 parent 145862a commit bba6819
Show file tree
Hide file tree
Showing 32 changed files with 855 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .devcontainer/avd-single-dc-l3ls/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"image": "ghcr.io/${localEnv:GITHUB_REPOSITORY}:single-dc-l3ls",
// containerEnv set the variables applied to entire container
"containerEnv": {
"ARISTA_TOKEN": "${localEnv:ARTOKEN}",
"CONTAINERWSF": "${containerWorkspaceFolder}",
"GITHUB_REPOSITORY": "${localEnv:GITHUB_REPOSITORY}",
"AVD_GITHUB_REPO": "${localEnv:AVD_GITHUB_REPO}",
"AVD_BRANCH_NAME": "${localEnv:AVD_BRANCH_NAME}"
},
"secrets": {
"ARTOKEN": {
"description": "token to auto-download EOS images from arista.com."
// "documentationUrl": "https://example.com/link/to/info"
},
"AVD_GITHUB_REPO": {
"description": "The name of the repository that will be used to install AVD collection. Set `aristanetworks/avd` to install from the original repository or use a fork."
// "documentationUrl": "https://example.com/link/to/info"
},
"AVD_BRANCH_NAME": {
"description": "The name of the branch that will be used to install AVD collection. For example: `devel`"
// "documentationUrl": "https://example.com/link/to/info"
}
},
"hostRequirements": {
"cpus": 8,
"memory": "32gb",
"storage": "64gb"
},
"postCreateCommand": "postCreate.sh",
"workspaceMount": "source=${localWorkspaceFolder}/demos/${containerWorkspaceFolder},target=/${containerWorkspaceFolder},type=bind",
"workspaceFolder": "/avd-single-dc-l3ls"
}
25 changes: 25 additions & 0 deletions .github/workflows/avd-single-dc-l3ls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: build container for Single DC L3LS

on:
push:
branches: [main]
paths:
- .github/workflows/avd-single-dc-l3ls.yml
- .github/workflows/container-build-child-workflow.yml
- containers/avd-single-dc-l3ls/**
workflow_dispatch:
branches: [main]

jobs:
build-demo-container:
uses: ./.github/workflows/container-build-child-workflow.yml
with:
container_name: "avd"
image_tags: "single-dc-l3ls"
from_image: "ghcr.io/aristanetworks/avd/dev"
from_variant: "python3.11"
username: "avd"
clab_version: "0.54.2"
ceos_lab_version: "4.32.0.1F"
git_init: True
42 changes: 42 additions & 0 deletions containers/avd-single-dc-l3ls/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG FROM_IMAGE
ARG FROM_VARIANT

FROM ${FROM_IMAGE}:${FROM_VARIANT}

ARG USERNAME
ARG CLAB_VERSION
ARG CEOS_LAB_VERSION_ARG
ARG GIT_INIT_ARG

ENV CEOS_LAB_VERSION=${CEOS_LAB_VERSION_ARG}
ENV GIT_INIT=${GIT_INIT_ARG}

USER root

# install some basic tools inside the container
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
sshpass \
iputils-ping \
htop \
&& rm -rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
&& apt-get clean

# copy postCreate script
COPY ./postCreate.sh /bin/postCreate.sh
RUN chmod +x /bin/postCreate.sh
# copy addAliases script
COPY ./addAliases.sh /bin/addAliases.sh
RUN chmod +x /bin/addAliases.sh

USER ${USERNAME}

RUN /bin/addAliases.sh

# install the latest containerlab, yamllint, cook-and-cut and eos-downloader
RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${CLAB_VERSION} \
&& pip3 install --user yamllint \
&& pip install --user "eos-downloader>=0.10.1" \
&& pip install --user passlib \
&& pip3 install anta==0.12.0
16 changes: 16 additions & 0 deletions containers/avd-single-dc-l3ls/.devcontainer/addAliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set +e


echo "alias dc1-spine1='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-spine2='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf1a='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf1b='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf2a='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf2b='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf1c='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf2c='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc

echo "alias dc1-leaf1-server1='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
echo "alias dc1-leaf2-server1='sshpass -p ansible ssh -o \"StrictHostKeyChecking no\" [email protected]'" >> ~/.zshrc
36 changes: 36 additions & 0 deletions containers/avd-single-dc-l3ls/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"build": {
"dockerfile": "Dockerfile",
"args": {
"FROM_IMAGE": "${localEnv:FROM_IMAGE}",
"FROM_VARIANT": "${localEnv:FROM_VARIANT}",
"USERNAME": "${localEnv:USERNAME}",
"CLAB_VERSION": "${localEnv:CLAB_VERSION}",
"CEOS_LAB_VERSION_ARG": "${localEnv:CEOS_LAB_VERSION_ARG}",
"GIT_INIT_ARG": "${localEnv:GIT_INIT_ARG}"
}
},
"customizations": {
"vscode": {
"extensions": [
// git essentials
"piotrpalarz.vscode-gitignore-generator",
"mhutchie.git-graph",
"donjayamanne.githistory",
// spell checker
"streetsidesoftware.code-spell-checker",
// drawio and tldraw
// excalidraw is pre-installed in universal
"hediet.vscode-drawio",
"tldraw-org.tldraw-vscode",
// markdown
"yzhang.markdown-all-in-one",
"bierner.markdown-checkbox",
"DavidAnson.vscode-markdownlint",
// various tools
"tuxtina.json2yaml",
"mutantdino.resourcemonitor"
]
}
}
}
25 changes: 25 additions & 0 deletions containers/avd-single-dc-l3ls/.devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set +e

# replace all markdown vars in demo directory
grep -rl '{{gh.repo_name}}' . --exclude-dir .git | xargs sed -i 's/'{{gh.repo_name}}'/'"${GITHUB_REPOSITORY##*/}"'/g'
grep -rl '{{gh.org_name}}' . --exclude-dir .git | xargs sed -i 's/'{{gh.org_name}}'/'"${GITHUB_REPOSITORY%%/*}"'/g'
grep -rl '{{gh.repository}}' . --exclude-dir .git | xargs sed -i 's@'{{gh.repository}}'@'"${GITHUB_REPOSITORY}"'@g'

ardl get eos --image-type cEOS --version ${CEOS_LAB_VERSION} --import-docker

# copy AVD inventory
mkdir ${CONTAINERWSF}/avd_inventory/
cp -r /home/avd/.ansible/collections/ansible_collections/arista/avd/examples/single-dc-l3ls/* ${CONTAINERWSF}/avd_inventory/

# init demo dir as Git repo if requested for this demo env
if ${GIT_INIT}; then
cd ${CONTAINERWSF}
git init
git config --global --add safe.directory ${PWD}
if [ -z "$(git config user.name)" ]; then git config user.name "Lab User"; fi
if [ -z "$(git config user.email)" ]; then git config user.email [email protected]; fi
git add .
git commit -m "git init"
fi
12 changes: 12 additions & 0 deletions demos/avd-avd-extended-workshop--part-1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ start: ## Deploy ceos lab
.PHONY: stop
stop: ## Destroy ceos lab
sudo containerlab destroy --debug --topo $(CURRENT_DIR)/clab/topology.clab.yml --cleanup

.PHONY: build
build: ## Generate AVD configs
cd $(CURRENT_DIR)/avd_inventory; ansible-playbook build.yml

.PHONY: deploy_eapi
deploy_eapi: ## Deploy AVD configs using eAPI
cd $(CURRENT_DIR)/avd_inventory; ansible-playbook deploy.yml

.PHONY: deploy_cvp
deploy_cvp: ## Deploy AVD configs using eAPI
cd $(CURRENT_DIR)/avd_inventory; ansible-playbook deploy-cvp.yml
120 changes: 120 additions & 0 deletions demos/avd-single-dc-l3ls/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,ansible,linux,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,ansible,linux,windows

### Ansible ###
*.retry

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,ansible,linux,windows

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

# ignore clab files
clab-*
*.bak

# ignore cv onboarding token
clab/cv-onboarding-token

# discard all config backups as we don't need them
avd_inventory/config_backup/

# gitignore downloaded cEOS-lab images
cEOS-lab-*

# ingnore images and other files not to be uploaded to GitHub
.gitignored/*
!.gitignored/.gitkeep
13 changes: 13 additions & 0 deletions demos/avd-single-dc-l3ls/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CURRENT_DIR := $(shell pwd)

.PHONY: help
help: ## Display help message
@grep -E '^[0-9a-zA-Z_-]+\.*[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: start
start: ## Deploy ceos lab
sudo containerlab deploy --debug --topo $(CURRENT_DIR)/clab/topology.clab.yml --max-workers 10 --timeout 5m --reconfigure

.PHONY: stop
stop: ## Destroy ceos lab
sudo containerlab destroy --debug --topo $(CURRENT_DIR)/clab/topology.clab.yml --cleanup
18 changes: 18 additions & 0 deletions demos/avd-single-dc-l3ls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Single DC L3LS

This lab is tested for:

cEOS-lab version: 4.32.0.1F
Containerlab Version: 0.54.2
Codespace Container Size
CPUs: 8
memory: 32 GB
storage: 64 GB

Last reviewed: 05/06/2024

Please check the lab materials:

- [Lab Documentation](https://{{gh.org_name}}.github.io/{{gh.repo_name}}/avd-single-dc-l3ls/avd-single-dc-l3ls/)
- [HTML Slides](https://{{gh.org_name}}.github.io/{{gh.repo_name}}/slides/avd-single-dc-l3ls.html)
- [PDF Slides](https://{{gh.org_name}}.github.io/{{gh.repo_name}}/pdfs/avd-single-dc-l3ls.pdf)
36 changes: 36 additions & 0 deletions demos/avd-single-dc-l3ls/clab/init-configs/dc1-leaf1-server1.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
hostname dc1-spine1
!
no aaa root
!
username ansible privilege 15 role network-admin secret ansible
!
vrf instance MGMT
!
ip name-server vrf MGMT 8.8.8.8
dns domain avd.lab
!
ntp local-interface vrf MGMT Management0
ntp server vrf MGMT time.apple.com
ntp server vrf MGMT time.google.com
ntp server vrf MGMT time.windows.com
!
service routing protocols model multi-agent
!
management api http-commands
protocol https
no shutdown
!
vrf MGMT
no shutdown
!
aaa authorization exec default local
!
interface Management0
vrf MGMT
ip address 172.16.1.11/24
!
ip route vrf MGMT 0.0.0.0/0 172.16.1.1
!
ip name-server vrf MGMT 8.8.8.8
!
end
Loading

0 comments on commit bba6819

Please sign in to comment.