Last active
August 29, 2015 14:07
-
-
Save nathwill/7b78f48e08d67e3b1d21 to your computer and use it in GitHub Desktop.
snippet of packer-centric makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
projs := $(basename $(wildcard *.json)) | |
cmds := validate inspect build fix | |
aliases := bootstrap rebuild | |
# Enable packer debug logging | |
PACKER_LOG := 1 | |
PACKER_LOG_PATH := /tmp/packer-debug | |
export PACKER_LOG PACKER_LOG_PATH | |
# call out rules that don't generate output | |
.PHONY: clean deps \ | |
$(cmds) $(foreach proj,$(projs), $(addsuffix -$(proj),$(cmds))) \ | |
all $(projs) | |
# dep management tasks | |
clean: | |
@rm -rf cookbooks | |
deps: cookbooks | |
cookbooks: | |
@berks vendor $@ | |
# auto-define global and per-proj rules for packer commands | |
define packer_cmd_rules | |
$1: $(addprefix $1-,$(projs)) | |
$(addprefix $1-,$(projs)): | |
@packer $1 $$(addsuffix .json,$$(subst $1-,,$$@)) | |
endef | |
$(foreach cmd,$(cmds), $(eval $(call packer_cmd_rules,$(cmd)))) | |
# auto generate global and per-proj fast-builds | |
all: $(projs) | |
$(projs): | |
@packer build \ | |
-var "base_image=nathwill/${@}" \ | |
$(addsuffix .json, $@) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment