-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (30 loc) · 793 Bytes
/
Copy pathMakefile
File metadata and controls
35 lines (30 loc) · 793 Bytes
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
VM_DIR := vagrant
VMs := $(notdir $(wildcard $(VM_DIR)/*))
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
.ONESHELL:
.SILENT:
.SUFFIXES:
help:
echo "Usage: make <target>"
echo "Targets:"
printf " %-10s %s\n" "help" "Display this help message"
$(foreach vm,$(VMs), printf " %-10s %s\n" "$(vm)" "Deploy $(vm)";)
printf " %-10s %s\n" "clean" "Destroy all VMs"
$(VMs):
cd $(VM_DIR)/$@
vagrant up
clean:
for vm in $(VMs); do \
status=$$(cd $(VM_DIR)/$$vm && vagrant status --machine-readable 2>/dev/null | grep ',state,' | cut -d',' -f4); \
case "$$status" in \
running|poweroff|saved) \
echo "$$vm: $$status"; \
(cd $(VM_DIR)/$$vm && vagrant destroy -f); \
;; \
*) \
echo "$$vm: $$status"; \
;; \
esac; \
done
.PHONY: help $(VMs) clean all test