-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
243 lines (222 loc) · 9.61 KB
/
Makefile
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
CURRENT_DIR := $(shell pwd)
#DOCKER_NAME ?= avd-quickstart
DOCKER_NAME ?= avd-evpnvxlan
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[0m%-30s\033[30m %s\n", $$1, $$2}'
.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: ## Generate inventory for EVPN AA
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: ## Generate inventory for EVPN MLAG
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
docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
-v /var/run/netns:/var/run/netns \
-v /var/lib/docker/containers:/var/lib/docker/containers \
--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)" \
ghcr.io/srl-labs/clab clab deploy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --reconfigure ;\
.PHONY: clab_destroy
clab_destroy: ## Destroy ceos lab
sudo docker run --rm -it --privileged \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/hosts:/etc/hosts \
-v /var/run/netns:/var/run/netns \
-v /var/lib/docker/containers:/var/lib/docker/containers \
--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)" \
ghcr.io/srl-labs/clab clab destroy --debug --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml --cleanup ; \
.PHONY: clab_inspect
clab_inspect: ## Inspect Containerlab
if [ "${_IN_CONTAINER}" = "True" ]; then \
sudo containerlab inspect --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)" \
test_clab:latest sudo containerlab inspect --topo $(CURRENT_DIR)/${AVD_REPOSITORY_NAME}/clab/$(CLAB_NAME).clab.yml ; \
fi
.PHONY: clab_graph
clab_graph: ## Build Containerlab 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 \
# python3 $(CURRENT_DIR)/$(AVD_REPOSITORY_NAME)/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: ansible-playbook playbooks/fabric-deploy-eapi.yml
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: ## Validate states: ansible-playbook playbooks/validate-states.yml
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: ## Snapshot: ansible-playbook playbooks/snapshot.yml
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