This repository was archived by the owner on Jul 3, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (211 loc) · 9.05 KB
/
Copy pathMakefile
File metadata and controls
229 lines (211 loc) · 9.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
CURRENT_DIR := $(shell pwd)
DOCKER_NAME ?= avd-quickstart
USERNAME := avd
USER_UID ?= $(shell id -u)
USER_GID ?= $(shell id -g)
PLATFORM ?= $(shell uname)
AVD_REPOSITORY_NAME := avd_lab
CLAB_NAME := ${AVD_REPOSITORY_NAME}
DOCKER_IMAGE_PRESENT := $(shell docker image ls | grep '^$(DOCKER_NAME)[[:space:]]*latest')
.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: prepare_macos
prepare_mac_os: ## Prepare Docker Desktop on MacOS for cEOS-based Containerlab
$(CURRENT_DIR)/MacOS_set_DockerDesktop.sh
.PHONY: build
build: ## Build docker image
docker build --rm --pull --no-cache -t avd-quickstart-temp-image -f $(CURRENT_DIR)/.devcontainer/Dockerfile . ; \
docker build -f $(CURRENT_DIR)/.devcontainer/updateUID.Dockerfile -t $(DOCKER_NAME):latest --build-arg BASE_IMAGE=avd-quickstart-temp-image --build-arg REMOTE_USER=$(USERNAME) --build-arg NEW_UID=$(USER_UID) --build-arg NEW_GID=$(USER_GID) --build-arg IMAGE_USER=$(USERNAME) . ; \
.PHONY: run
run: ## run docker image
if [ "${_IN_CONTAINER}" = "True" ]; then \
echo "There is no need to run another AVD quickstart container inside AVD quickstart container." ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest || true ; \
fi
.PHONY: inventory_evpn_aa
inventory_evpn_aa: ## onboard devices to CVP
if [ "${_IN_CONTAINER}" = "True" ]; then \
$(CURRENT_DIR)/cook_and_cut.py --input_directory CSVs_EVPN_AA ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest $(CURRENT_DIR)/cook_and_cut.py --input_directory CSVs_EVPN_AA ; \
fi
.PHONY: inventory_evpn_mlag
inventory_evpn_mlag: ## onboard devices to CVP
if [ "${_IN_CONTAINER}" = "True" ]; then \
$(CURRENT_DIR)/cook_and_cut.py --input_directory CSVs_EVPN_MLAG ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest $(CURRENT_DIR)/cook_and_cut.py --input_directory CSVs_EVPN_MLAG ; \
fi
.PHONY: clab_deploy
clab_deploy: ## Deploy ceos lab
if [ "${_IN_CONTAINER}" = "True" ]; then \
sudo containerlab deploy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --max-workers 2 --timeout 5m ;\
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest sudo containerlab deploy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --max-workers 2 --timeout 5m ;\
fi
.PHONY: clab_destroy
clab_destroy: ## Destroy ceos lab
if [ "${_IN_CONTAINER}" = "True" ]; then \
sudo containerlab destroy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --cleanup ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
test_clab:latest sudo containerlab destroy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --cleanup ; \
fi
.PHONY: clab_graph
clab_graph: ## Build lab graph
if [ "${_IN_CONTAINER}" = "True" ]; then \
sudo containerlab graph --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml ;\
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest sudo containerlab graph --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml ;\
fi
.PHONY: clean
clean: ## Remove all containerlab files and directories
sudo rm -rf $(AVD_REPOSITORY_NAME); sudo rm .cookiecutters/cookiecutter.json
.PHONY: rm
rm: clean ## Remove all containerlab files and directories
.PHONY: onboard
onboard: ## onboard devices to CVP
if [ "${_IN_CONTAINER}" = "True" ]; then \
$(CURRENT_DIR)/onboard_devices_to_cvp.py ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR) \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest $(CURRENT_DIR)/onboard_devices_to_cvp.py ; \
fi
.PHONY: avd_build_eapi
avd_build_eapi: ## build configs and configure switches via eAPI
if [ "${_IN_CONTAINER}" = "True" ]; then \
cd $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}; ansible-playbook playbooks/fabric-deploy-eapi.yml ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR)/${AVD_REPOSITORY_NAME} \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest ansible-playbook playbooks/fabric-deploy-eapi.yml ; \
fi
.PHONY: avd_build_cvp
avd_build_cvp: ## build configs and configure switches via eAPI
if [ "${_IN_CONTAINER}" = "True" ]; then \
cd $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}; ansible-playbook playbooks/fabric-deploy-cvp.yml ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR)/${AVD_REPOSITORY_NAME} \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest ansible-playbook playbooks/fabric-deploy-cvp.yml ; \
fi
.PHONY: avd_validate
avd_validate: ## build configs and configure switches via eAPI
if [ "${_IN_CONTAINER}" = "True" ]; then \
cd $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}; ansible-playbook playbooks/validate-states.yml ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR)/${AVD_REPOSITORY_NAME} \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest ansible-playbook playbooks/validate-states.yml ; \
fi
.PHONY: avd_snapshot
avd_snapshot: ## build configs and configure switches via eAPI
if [ "${_IN_CONTAINER}" = "True" ]; then \
cd $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}; ansible-playbook playbooks/snapshot.yml ; \
else \
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
--pid="host" \
-w $(CURRENT_DIR)/${AVD_REPOSITORY_NAME} \
-v $(CURRENT_DIR):$(CURRENT_DIR) \
-v $(CURRENT_DIR)/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro \
-e AVD_GIT_USER="$(shell git config --get user.name)" \
-e AVD_GIT_EMAIL="$(shell git config --get user.email)" \
$(DOCKER_NAME):latest ansible-playbook playbooks/snapshot.yml ; \
fi