1+ # runs at parse time on every invocation: ensure certs exist, then (re)generate .env
2+ $(shell [ -f files/certs/ca.pem ] || ./scripts/gen-certs.sh)
3+ $(shell ./env.sh 1>&2)
4+ -include .env
5+
16.DEFAULT_GOAL := up
27.EXPORT_ALL_VARIABLES :
38
4- -include .env
9+ # disable built-in implicit rules (e.g. the "%: %.sh" rule that silently turns a
10+ # stray/misspelled prerequisite into a junk executable instead of erroring out)
11+ MAKEFLAGS += --no-builtin-rules
12+ .SUFFIXES :
513
614# Commands
715YQ =docker run --rm -i -v $(shell pwd) :/workdir mikefarah/yq:4
816
917KINDCONFIG := $(or $(KINDCONFIG ) ,control-plane/kind.yaml)
1018KUBECONFIG := $(shell pwd) /.kubeconfig
1119
12- METALCTL_HMAC := $(or $(METALCTL_HMAC ) ,metal-admin)
13- METALCTL_API_URL := $(or $(METALCTL_API_URL ) ,http://api.172.42.0.42.nip.io:8080/metal)
14- METAL_APIV2_URL := $(or $(METAL_APIV2_URL ) ,http://v2.172.42.0.42.nip.io:8080)
15-
1620MKE2FS_CONFIG := $(shell pwd) /mke2fs.conf
1721# Default values
1822CONTAINERLAB =$(shell which containerlab)
@@ -80,7 +84,7 @@ COMPOSE_ARGS += $(if $(MINI_LAB_HELM_CHARTS),-f compose.dev/helm-charts.yaml)
8084endif
8185
8286.PHONY : up
83- up : env gen-certs verify-deployment-image control-plane-bake partition-bake
87+ up : gen-certs verify-deployment-image control-plane-bake partition-bake
8488 @chmod 600 files/ssh/id_ed25519
8589 docker compose $(COMPOSE_ARGS ) up --pull=always --abort-on-container-failure --remove-orphans --force-recreate control-plane partition
8690 @$(MAKE ) --no-print-directory start-machines
@@ -98,23 +102,12 @@ restart: down up
98102.PHONY : down
99103down : cleanup
100104
101- .PHONY : gen-certs
102- gen-certs :
103- @if ! [ -f " files/certs/ca.pem" ]; then \
104- echo " certificate generation required, running cfssl container" ; \
105- docker run --rm \
106- --user $$(id -u ) :$$(id -g ) \
107- --entrypoint bash \
108- -v ${PWD} :/work \
109- cfssl/cfssl /work/scripts/roll_certs.sh; fi
110-
111105.PHONY : roll-certs
112106roll-certs :
113- rm files/certs/ca.pem
114- $(MAKE ) gen-certs
107+ ./scripts/gen-certs.sh
115108
116109.PHONY : control-plane
117- control-plane : control-plane-bake env
110+ control-plane : control-plane-bake
118111 docker compose $(COMPOSE_ARGS ) up --remove-orphans --force-recreate control-plane
119112
120113.PHONY : create-proxy-registries
@@ -152,7 +145,7 @@ endif
152145 ./scripts/deactivate_offloading.sh; fi
153146
154147.PHONY : verify-deployment-image
155- verify-deployment-image : env
148+ verify-deployment-image :
156149 @if which cosign 1> /dev/null 2> /dev/null; then \
157150 echo -e " \033[0;32mcosign is installed, verifying deployment base image\033[0m" && \
158151 . ./.env && cosign verify --key files/cosign.pub ghcr.io/metal-stack/metal-deployment-base:$$ DEPLOYMENT_BASE_IMAGE_TAG; \
@@ -178,9 +171,14 @@ external_network:
178171 sudo ip -6 route add 2001:db8:0:113::/64 via 2001:db8:0:1::1 dev mini_lab_ext; \
179172 fi
180173
181- .PHONY : env
182- env :
183- @./env.sh
174+ files/certs/ca.pem :
175+ @./scripts/gen-certs.sh
176+
177+ .env : files/certs/ca.pem
178+ @./env.sh 1>&2
179+
180+ .PHONY : gen-certs # keep as a convenience alias
181+ gen-certs : files/certs/ca.pem
184182
185183.PHONY : cleanup
186184cleanup : cleanup-control-plane cleanup-partition
@@ -202,7 +200,7 @@ cleanup-partition:
202200 docker network rm --force mini_lab_ext
203201
204202.PHONY : _privatenet
205- _privatenet : env
203+ _privatenet :
206204 docker compose run $(DOCKER_COMPOSE_RUN_ARG ) metalctl network list --name user-private-network | grep user-private-network || docker compose run $(DOCKER_COMPOSE_RUN_ARG ) metalctl network allocate --partition mini-lab --project 00000000-0000-0000-0000-000000000001 --name user-private-network
207205
208206.PHONY : update-userdata
@@ -245,7 +243,7 @@ public-ipv6:
245243 @docker compose run $(DOCKER_COMPOSE_RUN_ARG ) metalctl network ip create --name test --network internet-mini-lab --project 00000000-0000-0000-0000-000000000001 --addressfamily IPv6 -o template --template " {{ .ipaddress }}"
246244
247245.PHONY : ls
248- ls : env
246+ ls :
249247 docker compose run $(DOCKER_COMPOSE_RUN_ARG ) metalctl machine ls
250248
251249# # SWITCH MANAGEMENT ##
@@ -351,7 +349,7 @@ console-machine04:
351349 @$(MAKE ) --no-print-directory _console VM=machine04
352350
353351.PHONY : _password
354- _password : env
352+ _password :
355353 docker compose run $(DOCKER_COMPOSE_RUN_ARG ) metalctl machine consolepassword $(MACHINE_UUID )
356354
357355.PHONY : password-machine01
@@ -440,6 +438,7 @@ dev-env:
440438 @echo " export METALCTL_HMAC=${METALCTL_HMAC} "
441439 @echo " export METAL_APIV2_URL=${METAL_APIV2_URL} "
442440 @echo " export KUBECONFIG=$( KUBECONFIG) "
441+ @echo " export METALCTL_CERTIFICATE_AUTHORITY_DATA=$( METALCTL_CERTIFICATE_AUTHORITY_DATA) "
443442
444443build-dell-sonic :
445444 if [ ! -f " sonic-vs.img" ]; then \
0 commit comments