From 6417c24d051f988305d3316413be8a896a07d4f1 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 21 Aug 2018 18:22:05 +0200 Subject: split directories for ansible roles * ANSIBLE_DIR_CORE for slx-builder repo * ANSIBLE_DIR_PROV for provisioning repos --- Makefile | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index d90188c..25430d1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ # * support ssh as user instead of root # * testing target PACKER ?= packer -ANSIBLE_DIR ?= ansible-roles +ANSIBLE_DIR_CORE ?= ansible-roles +ANSIBLE_DIR_PROV ?= ansible-roles-prov HASHER ?= sha256sum SHELL := /usr/bin/env bash @@ -47,7 +48,7 @@ override PROVISIONER = $(BUILDER_$(PROVISIONER_SELECTED)_PROV) TEMPLATES := $(basename $(filter-out base.json,$(wildcard *.json))) # The provisioning flavors, detected as ansible-roles/setup-.yml -FLAVORS := $(patsubst $(ANSIBLE_DIR)/setup-%.yml,%, $(wildcard $(ANSIBLE_DIR)/setup-*.yml)) +FLAVORS := $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, $(wildcard $(ANSIBLE_DIR_PROV)/setup-*.yml)) BASETARGETS := $(foreach template, $(TEMPLATES), $(template)/base) PROVTARGETS := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(template)/$(flavor))) @@ -104,7 +105,8 @@ ifdef VERBOSE $(info packer: executable: $(PACKER)) $(info packer: options: $(PACKER_OPTS)) $(info ) - $(info ansible: directory: $(ANSIBLE_DIR)) + $(info ansible: core: $(ANSIBLE_DIR_CORE)) + $(info ansible: flavors: $(ANSIBLE_DIR_PROV)) $(info ) $(info builder: available: $(AVAILABLE_BUILDERS)) $(info builder: chosen: $(BUILDER)) @@ -131,7 +133,7 @@ $(BASETARGETS): $(PACKER_OPTS) \ -var='vm_name=rootfs-image' \ -var='output_directory=$(@D)/base' \ - -var='playbook=$(ANSIBLE_DIR)/slx-builder.yml' \ + -var='playbook=$(ANSIBLE_DIR_CORE)/slx-builder.yml' \ -var='extra_ansible_args=-t,$(INIT_TAG)' \ $(@D).json @echo "$(ROOTPW)" | $(HASHER) > $(@D)/base/rootpw.$(HASHER) @@ -143,14 +145,14 @@ $(foreach flav, $(FLAVORS), %/$(flav)): %/base $(eval BUILD_DIR := $(@D)/$(@F).$(TIMESTAMP)) $(info ** Provisioning '$(@D)' with '$(@F)' **) @mkdir -p $(BUILD_DIR) - @cp -r $(ANSIBLE_DIR) $(BUILD_DIR)/$(ANSIBLE_DIR) + @cp -r $(ANSIBLE_DIR_PROV) $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) @ln -sfn $(@F).$(TIMESTAMP) $(@D)/$(@F).latest $(PACKER) build -only=$(PROVISIONER) \ $(PACKER_OPTS) \ -var='vm_name=rootfs-image' \ -var='output_directory=$(BUILD_DIR)/build' \ -var='base_image=$(@D)/base/rootfs-image' \ - -var='playbook=$(BUILD_DIR)/$(ANSIBLE_DIR)/setup-$(@F).yml' \ + -var='playbook=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(@F).yml' \ ansible-provisioner.json @@ -161,18 +163,18 @@ $(BOOTTARGETS): $(@D),\ $(@D).$(TIMESTAMP)/build)) $(eval ANSIBLE_DIR_CUR := $(if $(filter base,$(notdir $(@D))),\ - $(ANSIBLE_DIR),\ - $(@D).$(TIMESTAMP)/$(ANSIBLE_DIR))) + $(ANSIBLE_DIR_PROV),\ + $(@D).$(TIMESTAMP)/$(ANSIBLE_DIR_PROV))) $(info ** Generating boot files for '$(BUILD_DIR)') $(PACKER) build -only=$(PROVISIONER) \ $(PACKER_OPTS) \ -var='vm_name=rootfs-image.tmp' \ -var='output_directory=$(BUILD_DIR)/tmp' \ -var='base_image=$(BUILD_DIR)/rootfs-image' \ - -var='playbook=$(ANSIBLE_DIR)/slx-builder.yml' \ + -var='playbook=$(ANSIBLE_DIR_CORE)/slx-builder.yml' \ -var="extra_ansible_args=-t,install,-t,build" \ ansible-provisioner.json - @mv $(ANSIBLE_DIR_CUR)/boot_files $(BUILD_DIR)/boot + @mv $(ANSIBLE_DIR_CORE)/boot_files $(BUILD_DIR)/boot $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) @@ -229,18 +231,19 @@ help: @printf "\t<{base,provisioning}_target>/boot\n" @echo @echo "Available options are:" - @printf "\tANSIBLE_DIR: Set directory with ansible roles (def: ansible-roles)\n" - @printf "\tBUILDER: Set an ISO builder, do not autodetect\n" - @printf "\tPROVISIONER: Set a provisioning builder, do not autodetect\n" - @printf "\tDEBUG: Enable debug mode in packer (includes VERBOSE)\n" - @printf "\t DEBUG= Enable enhanced on-error handling\n" - @printf "\t DEBUG=STEP Enable step by step debugging in packer\n" - @printf "\tHASHER: Set wanted hasher (def: sha256sum)\n" - @printf "\tPACKER: Set packer executable (def: packer)\n" - @printf "\tPACKER_OPTS: Set packer options\n" - @printf "\tROOTPW: Set root password for output image\n" - @printf "\tVERBOSE: Enable verbose output\n" - @printf "\tWINDOW: Disable headless mode\n" + @printf "\tANSIBLE_DIR_CORE: Set directory with ansible roles for building initramfs (def: ansible-roles)\n" + @printf "\tANSIBLE_DIR_PROV: Set directory with ansible roles for provisioning (def: ansible-roles-prov)\n" + @printf "\tBUILDER: Set an ISO builder, do not autodetect\n" + @printf "\tPROVISIONER: Set a provisioning builder, do not autodetect\n" + @printf "\tDEBUG: Enable debug mode in packer (includes VERBOSE)\n" + @printf "\t DEBUG= Enable enhanced on-error handling\n" + @printf "\t DEBUG=STEP Enable step by step debugging in packer\n" + @printf "\tHASHER: Set wanted hasher (def: sha256sum)\n" + @printf "\tPACKER: Set packer executable (def: packer)\n" + @printf "\tPACKER_OPTS: Set packer options\n" + @printf "\tROOTPW: Set root password for output image\n" + @printf "\tVERBOSE: Enable verbose output\n" + @printf "\tWINDOW: Disable headless mode\n" @echo @echo "Clean targets are:" @printf "\tclean_except_last\n" -- cgit v1.2.3-55-g7522