summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 31 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index 789dcbf..162607c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
# Simple Makefile to build base VM images using packer and ansible
# TODO
-# * support ssh per user instead of root
-# * support building with non-qemu builders and convert to qemu afterwards
-# * testing target
-# * auto-detect flavors
+# * support ssh per user instead of root
+# * support building with non-qemu builders and convert to qemu afterwards
+# * testing target
+# * auto-detect flavors
PACKER=packer
ANSIBLE_DIR=ansible-roles
# the "provisioning" flavor, expects a 'setup-<flavor>.yml' playbook
@@ -12,29 +12,29 @@ FLAVORS := $(patsubst $(ANSIBLE_DIR)/setup-%.yml,%, $(wildcard $(ANSIBLE_DIR)/se
SUPPORTED_BUILDERS = qemu virtualbox-iso vmware-iso
# check which hypervisors are available
ifeq ($(shell which qemu-system-$(shell uname -m | sed 's/i686/i386/') 2>&1 > /dev/null && echo $$?), 0)
-AVAILABLE_BUILDERS += qemu
-BUILDER := qemu
+ AVAILABLE_BUILDERS += qemu
+ BUILDER := qemu
endif
ifndef BUILDER
-ifeq ($(shell which virtualbox 2>&1 > /dev/null && echo $$?), 0)
-AVAILABLE_BUILDERS += virtualbox-iso
-BUILDER := virtualbox-iso
-endif
+ ifeq ($(shell which virtualbox 2>&1 > /dev/null && echo $$?), 0)
+ AVAILABLE_BUILDERS += virtualbox-iso
+ BUILDER := virtualbox-iso
+ endif
endif
ifndef BUILDER
-ifeq ($(shell which vmplayer 2>&1 > /dev/null && echo $$?), 0)
-AVAILABLE_BUILDERS += vmware-iso
-BUILDER := vmware-iso
-endif
+ ifeq ($(shell which vmplayer 2>&1 > /dev/null && echo $$?), 0)
+ AVAILABLE_BUILDERS += vmware-iso
+ BUILDER := vmware-iso
+ endif
endif
ifndef BUILDER
-$(error No usable builder found! Please install a hypervisor...)
+ $(error No usable builder found! Please install a hypervisor...)
endif
MISSING_BUILDERS = $(filter-out $(AVAILABLE_BUILDERS),$(SUPPORTED_BUILDERS))
ifneq ($(words $(MISSING_BUILDERS)), 0)
-$(info Builders missing on this system: $(MISSING_BUILDERS))
-$(info If you wish to use these, install the corresponding hypervisor and retry.)
-$(info )
+ $(info Builders missing on this system: $(MISSING_BUILDERS))
+ $(info If you wish to use these, install the corresponding hypervisor and retry.)
+ $(info )
endif
TEMPLATES := $(basename $(filter-out base.json,$(wildcard *.json)))
@@ -46,20 +46,20 @@ BOOTTARGETS += $(foreach prov, $(PROVTARGETS), $(prov)/boot)
PACKER_OPTS := -var-file=base.json
ifdef DEBUG
- PACKER_OPTS += -debug
- PACKER_OPTS += -var='headless=false'
+ PACKER_OPTS += -debug
+ PACKER_OPTS += -var='headless=false'
endif
.PHONY: all help clean
all: help
##
-# Creating base images
+# Creating base images
##
$(BASETARGETS):
-ifndef ROOTPW
- $(error ROOTPW is not set)
-endif
+ ifndef ROOTPW
+ $(error ROOTPW is not set)
+ endif
$(info ** Building template '$(@D)' using '$(BUILDER)' **)
$(PACKER) build -only=$(BUILDER) \
$(PACKER_OPTS) \
@@ -73,7 +73,7 @@ endif
@echo "** Success **"
##
-# Provisioning images
+# Provisioning images
##
# This should still only use base images
$(PROVTARGETS):
@@ -99,7 +99,7 @@ $(foreach flav, $(FLAVORS), %/$(flav)): %/base
# This should use provisioned image
$(BOOTTARGETS):
%/boot: %
-# no evil eval tricks...
+ # no evil eval tricks...
$(info ** Generating boot files for '$(patsubst %/,%,$(dir $(@D))):$(notdir $(@D))' **)
$(PACKER) build -only=$(BUILDER) \
$(PACKER_OPTS) \
@@ -110,16 +110,16 @@ $(BOOTTARGETS):
$(ANSIBLE_DIR)/run-playbook-only.json
@test -f $(ANSIBLE_DIR)/boot_files/initramfs || false
@-test -d $(patsubst %/,%,$(dir $(@D)))/$(notdir $(@D))/boot && \
- rm -rf $(patsubst %/,%,$(dir $(@D)))/$(notdir $(@D))/boot
+ rm -rf $(patsubst %/,%,$(dir $(@D)))/$(notdir $(@D))/boot
@mv $(ANSIBLE_DIR)/boot_files $(patsubst %/,%,$(dir $(@D)))/$(notdir $(@D))/boot
-ifndef DEBUG
- @rm -rf output-$(patsubst %/,%,$(dir $(@D)))/
-endif
+ ifndef DEBUG
+ @rm -rf output-$(patsubst %/,%,$(dir $(@D)))/
+ endif
@echo "** Success **"
help:
@echo "General syntax: <template>/<flavor>[/boot]"
- @echo
+ # @echo
@echo "Detected builders:"
@(for B in $(AVAILABLE_BUILDERS); do echo -e "\t$$B"; done)
@echo