From dc2de921c387edf0c215b33109f0b6a255f753fd Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 11 Apr 2017 18:46:54 +0200 Subject: introduce Makefile to simplify building templates updated ubuntu/centos templates to fixed output names, moved manifest.json to builder's subfolder, updated README.md to reflect the changes --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ README.md | 41 +++++++++++++++++++++++++++++------------ centos-7.3-x86_64.json | 10 +++++----- ubuntu-16.04-amd64.json | 14 +++++++------- 4 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..012ccbb --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +# Simple Makefile to build packer templates +# TODO: +# - allow overriding packer variables +# - check for hypervisors (and invalidate targets) +# - provisioning logic +BUILDERS = qemu vmware-iso virtualbox-iso +TEMPLATES := $(basename $(filter-out base.json,$(wildcard *.json))) +TARGETS := $(foreach builder, $(BUILDERS), $(foreach template, $(TEMPLATES), $(builder)/$(template))) +PACKER_OPTS := -var-file=base.json + +.PHONY: all list clean +all: list + +$(TARGETS): +ifndef ROOTPW + $(error ROOTPW is not set) +endif + + $(info Building '$(@F)' with '$(@D)') + packer build -only=$(@D) \ + $(PACKER_OPTS) \ + -var='vm_name=$(@F)' \ + $(@F).json + +list: + $(info Possible targets:) + @(for F in $(TARGETS); do echo -e "\t$$F" ; done) + +clean: + $(foreach builder,$(BUILDERS),rm -rf $(builder)/;) + +# convenience do-nothing targets for auto-complete +qemu/ubuntu-16.04-amd64: +qemu/centos-7.3-x86_64: +virtualbox-iso/ubuntu-16.04-amd64: +virtualbox-iso/centos-7.3-x86_64: +vmware-iso/ubuntu-16.04-amd64: +vmware-iso/centos-7.3-x86_64: diff --git a/README.md b/README.md index aefd6d9..295e3b0 100644 --- a/README.md +++ b/README.md @@ -15,24 +15,24 @@ The root password is expected to be in the ROOTPW environment variable. The installation procedure will fail without it! Basic usage: +```shell ROOTPW= packer build -var-file=base.json