diff options
author | Michael Janczyk | 2023-10-13 16:15:43 +0200 |
---|---|---|
committer | Michael Janczyk | 2023-10-13 16:15:43 +0200 |
commit | 70aa9513e848df4cb1d05bd0f85d9974f3f731d3 (patch) | |
tree | 67d4adc506a0a9c8dae1f086de36cfd52dea4aea | |
parent | hcl2: Makefile: change example for PKR_VAR_. (diff) | |
download | packer-templates-70aa9513e848df4cb1d05bd0f85d9974f3f731d3.tar.gz packer-templates-70aa9513e848df4cb1d05bd0f85d9974f3f731d3.tar.xz packer-templates-70aa9513e848df4cb1d05bd0f85d9974f3f731d3.zip |
move hcl2 code to main directory.
-rw-r--r-- | Makefile | 369 | ||||
-rw-r--r-- | alma-8-x86_64/base.pkrvars.hcl (renamed from hcl2/alma-8-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | alma-8-x86_64/http/anaconda-ks.cfg (renamed from hcl2/alma-8-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | alma-9-x86_64/base.pkrvars.hcl (renamed from hcl2/alma-9-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | alma-9-x86_64/http/anaconda-ks.cfg (renamed from hcl2/alma-9-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | ansible-provisioner.json | 56 | ||||
-rw-r--r-- | base.json | 8 | ||||
-rw-r--r-- | base.pkr.hcl (renamed from hcl2/base.pkr.hcl) | 0 | ||||
-rw-r--r-- | centos-7-x86_64.json | 49 | ||||
-rw-r--r-- | centos-8-x86_64.json | 46 | ||||
-rw-r--r-- | centos-8-x86_64/base.pkrvars.hcl (renamed from hcl2/centos-8-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | centos-8-x86_64/http/anaconda-ks.cfg (renamed from hcl2/centos-8-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | centos-9-x86_64/base.pkrvars.hcl (renamed from hcl2/centos-9-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | centos-9-x86_64/http/anaconda-ks.cfg (renamed from hcl2/centos-9-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | debian-10.4-amd64.json | 50 | ||||
-rw-r--r-- | flavor.pkr.hcl (renamed from hcl2/flavor.pkr.hcl) | 0 | ||||
-rw-r--r-- | hcl2/Makefile | 287 | ||||
l--------- | http/centos-7 | 1 | ||||
-rw-r--r-- | http/centos-8/anaconda-ks.cfg | 51 | ||||
-rw-r--r-- | http/centos/anaconda-ks.cfg | 51 | ||||
l--------- | http/debian-10.4 | 1 | ||||
-rw-r--r-- | http/debian/preseed.cfg | 63 | ||||
l--------- | http/rocky-8 | 1 | ||||
l--------- | http/rocky-9 | 1 | ||||
-rw-r--r-- | http/rocky/anaconda-ks.cfg | 104 | ||||
l--------- | http/ubuntu-18.04 | 1 | ||||
-rw-r--r-- | http/ubuntu/preseed.cfg | 63 | ||||
-rw-r--r-- | rocky-8-x86_64.json | 46 | ||||
-rw-r--r-- | rocky-8-x86_64/base.pkrvars.hcl (renamed from hcl2/rocky-8-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | rocky-8-x86_64/http/anaconda-ks.cfg (renamed from hcl2/rocky-8-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | rocky-9-x86_64.json | 46 | ||||
-rw-r--r-- | rocky-9-x86_64/base.pkrvars.hcl (renamed from hcl2/rocky-9-x86_64/base.pkrvars.hcl) | 0 | ||||
-rw-r--r-- | rocky-9-x86_64/http/anaconda-ks.cfg (renamed from hcl2/rocky-9-x86_64/http/anaconda-ks.cfg) | 0 | ||||
-rw-r--r-- | source.pkr.hcl (renamed from hcl2/source.pkr.hcl) | 0 | ||||
-rw-r--r-- | ubuntu-18.04-amd64.json | 52 | ||||
-rw-r--r-- | variables.pkr.hcl (renamed from hcl2/variables.pkr.hcl) | 0 |
36 files changed, 167 insertions, 1179 deletions
@@ -2,73 +2,63 @@ # TODO # * support ssh as user instead of root # * testing target -PACKER ?= packer -ANSIBLE_DIR_CORE ?= ansible-dracut -ANSIBLE_DIR_PROV ?= ansible-roles-prov -HASHER ?= sha256sum -SHELL := /usr/bin/env bash +PACKER ?= packer +ANSIBLE_DIR_BOOT ?= ansible-dracut +ANSIBLE_DIR_PROV ?= ansible-roles-prov +HASHER ?= sha256sum +SHELL := /usr/bin/env bash +BUILDS := builds +ARCH := $(shell uname -m | sed 's/i686/i386/') -ARCH := $(shell uname -m | sed 's/i686/i386/') +AVAILABLE_BUILDERS := QEMU +BUILDER_QEMU_EXE := qemu-system-$(ARCH) +BUILDER_QEMU_NAME := qemu +BUILDER_QEMU_PROV := $(BUILDER_QEMU_NAME) -BUILDER_QEMU_EXE := qemu-system-$(ARCH) -BUILDER_QEMU_NAME := qemu -BUILDER_QEMU_PROV := $(BUILDER_QEMU_NAME) - -BUILDER_VMWARE_EXE := vmware -BUILDER_VMWARE_NAME := vmware-iso -BUILDER_VMWARE_PROV := vmware-vmx - -BUILDER_VIRTUALBOX_EXE := virtualbox -BUILDER_VIRTUALBOX_NAME := virtualbox-iso -BUILDER_VIRTUALBOX_PROV := virtualbox-ovf - -BUILDERS := QEMU VMWARE VIRTUALBOX - - -$(foreach cur, $(BUILDERS),\ - $(if $(shell command -v $(BUILDER_$(cur)_EXE)),\ - $(eval AVAILABLE_BUILDERS += $(cur)))) - - -# If now BUILDER or PROVISIONER was specified on the command line, take the -# first available one; otherwise use that specified one. -BUILDER_SELECTED := $(strip $(if $(filter $(BUILDER),$(AVAILABLE_BUILDERS)),\ - $(BUILDER),\ - $(firstword $(AVAILABLE_BUILDERS)))) -PROVISIONER_SELECTED := $(strip $(if $(filter $(PROVISIONER),$(AVAILABLE_BUILDERS)),\ - $(PROVISIONER),\ - $(BUILDER_SELECTED))) - -override BUILDER = $(BUILDER_$(BUILDER_SELECTED)_NAME) -override PROVISIONER = $(BUILDER_$(PROVISIONER_SELECTED)_PROV) +BUILDERS := qemu +override BUILDER := qemu +override PROVISIONER := qemu # The packer templates, detected as *.json (excluding base.json) -TEMPLATES := $(basename $(filter-out base.json ansible-provisioner.json,$(wildcard *.json))) - -# The provisioning flavors, detected as ansible-roles/setup-<flavor>.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))) -REPROVTARGETS := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(filter-out $(template)/$(flavor).latest,$(wildcard $(template)/$(flavor).*)))) -COMPRESSPOSSIBLE := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(wildcard $(template)/$(flavor).*))) -COMPRESSTARGETS := $(foreach possible, $(COMPRESSPOSSIBLE), $(possible)/compress) -BOOTTARGETS := $(foreach template, $(TEMPLATES), $(template)/base/boot) -BOOTTARGETS += $(foreach prov, $(PROVTARGETS), $(prov)/boot) -CURBOOTTARGETS := $(foreach prov, $(REPROVTARGETS), $(prov)/boot) -BASERMTARGETS := $(foreach target, $(BASETARGETS), rm/$(target)) -PROVRMTARGETS := $(foreach target, $(REPROVTARGETS), rm/$(target)) - +TEMPLATES := $(patsubst %/,%,$(dir $(wildcard */base.pkrvars.hcl))) + +# The provisioning flavors, detected as ansible-<flavor>/setup-<flavor>.yml +# Find all paths beginnig with "ansible-" and and save this suffix in PATTERNS +PATTERNS := $(patsubst ansible-%, %, $(wildcard ansible-*)) +# Extract <flavor> from ansible-<flavor>/setup-<flavor>.yml using PATTERNS as <flavor> +FLAVORS := $(foreach p, $(PATTERNS), \ + $(patsubst ansible-$(p)/setup-$(p).yml, $(p), \ + $(wildcard ansible-$(p)/setup-$(p).yml))) +# Extra flavor from variable ANSIBLE_DIR_PROV, using pattern ANSIBLE_DIR_PROV/setup-<flavor>.yml +FLAVORS += $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, \ + $(wildcard $(ANSIBLE_DIR_PROV)/setup-*.yml)) +FLAVORS := $(strip $(FLAVORS)) + +BASETARGETS := $(strip $(foreach t, $(TEMPLATES), $(t)/base)) +PROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), $(t)/$(f)))) +PROVIMAGES := $(strip $(foreach f, $(FLAVORS), \ + $(foreach t, $(TEMPLATES), $(t)/$(f): %/$(f): %/base))) +REPROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), \ + $(filter-out $(t)/$(f).latest, \ + $(wildcard $(t)/$(f).*))))) +COMPRESSPOSSIBLE := $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), $(wildcard $(t)/$(f).*))) +COMPRESSTARGETS := $(foreach p, $(COMPRESSPOSSIBLE), $(p)/compress) +BOOTTARGETS := $(foreach t, $(TEMPLATES), $(t)/base/boot) +BOOTTARGETS += $(foreach p, $(PROVTARGETS), $(p)/boot) +BOOTTARGETS := $(strip $(BOOTTARGETS)) +CURBOOTTARGETS := $(foreach p, $(REPROVTARGETS), $(p)/boot) +BASERMTARGETS := $(foreach t, $(BASETARGETS), rm/$(t)) +PROVRMTARGETS := $(foreach t, $(REPROVTARGETS), rm/$(t)) ifndef ANSIBLE_PROV_EXTRA_ARGS ANSIBLE_PROV_EXTRA_ARGS := endif -#override ANSIBLE_PROV_EXTRA_ARGS += --scp-extra-args,"-O" - -override PACKER_OPTS += -var-file=base.json ifdef DEBUG VERBOSE := 1 ifeq ($(DEBUG),STEP) @@ -78,147 +68,127 @@ ifdef DEBUG endif endif +ifdef FORCE + override PACKER_OPTS += -force +endif ifdef WINDOW - override PACKER_OPTS += -var='headless=false' + override PACKER_OPTS += -var headless=false endif +override PACKER_OPTS += -warn-on-undeclared-var # We support parallel Provisioning packer builds. # To ensure data consistency we save the used ansible roles before executing in # its own environment, tagged by the current date & time. TIMESTAMP := $(shell date "+%Y-%m-%d_%H-%M-%S") - -# The ROOTPW is only needed for the base, boot and provisioning targets. -# In every other case it must not be checked as it should be possible to call -# help or cleanup without the need of defining the password. -PW_NEEDED := $(filter $(strip $(BASETARGETS) $(PROVTARGETS) $(BOOTTARGETS)),$(MAKECMDGOALS)) -ifneq ($(PW_NEEDED),) - ifeq ($(strip $(ROOTPW)),) - $(error No root password is set, set it as ROOTPW in your environment.) - else - $(foreach cur,$(PW_NEEDED),\ - $(eval cur_dir := $(firstword $(subst /, ,$(cur)))/base)\ - $(if $(shell test -d "$(cur_dir)" && echo yes),\ - $(shell echo "$(ROOTPW)" | $(HASHER) --check --status "$(cur_dir)/rootpw.$(HASHER)")\ - $(if $(filter 1,$(.SHELLSTATUS)),\ - $(error The wrong ROOTPW is set. Please correct it)))) - endif -endif - - ifdef VERBOSE - $(info root password: $(ROOTPW)) - $(info hasher: $(HASHER)) - $(info ) $(info timestamp: $(TIMESTAMP)) $(info ) $(info packer: executable: $(PACKER)) $(info packer: options: $(PACKER_OPTS)) + $(info hasher: $(HASHER)) $(info ) - $(info ansible: core: $(ANSIBLE_DIR_CORE)) - $(info ansible: flavors: $(ANSIBLE_DIR_PROV)) + $(info ansible: boot: $(ANSIBLE_DIR_BOOT)) + $(info ansible: flavors: $(FLAVORS)) $(info ) $(info builder: available: $(AVAILABLE_BUILDERS)) $(info builder: chosen: $(BUILDER)) $(info ) - $(info targets: base: $(strip $(BASETARGETS))) - $(info targets: boot: $(strip $(BOOTTARGETS))) - $(info targets: provision: $(strip $(PROVTARGETS))) + $(info targets: base: $(BASETARGETS)) + $(info targets: boot: $(BOOTTARGETS)) + $(info targets: provision: $(PROVTARGETS)) + $(info targets: reprovision: $(REPROVTARGETS)) $(info ) + override PACKER := PACKER_LOG=1 $(PACKER) endif - .PHONY: help clean_except_last clean_bases clean_all clean_failed backinglock $(REPROVTARGETS) help: - # Creating base images. When DRACUT_INIT is specified, the dracut module # repository will be initially cloned and its required components (dnbd3, # xmount, libxmount-qemu) will be pre-build to accelerate subsequent builds. $(BASETARGETS): $(info ** Building template '$(@D)' using '$(BUILDER)' **) - $(eval INIT_TAG := $(if $(DRACUT_INIT),\ - install,\ - untagged)) - $(PACKER) build -only=$(BUILDER) \ - $(PACKER_OPTS) \ - -var='vm_name=rootfs-image' \ - -var='output_directory=$(@D)/base' \ - -var='playbook=$(ANSIBLE_DIR_CORE)/slx-builder.yml' \ - -var='extra_ansible_args=-t,$(INIT_TAG)' \ - $(@D).json - @echo "$(ROOTPW)" | $(HASHER) > $(@D)/base/rootpw.$(HASHER) - + $(eval INIT_TAG := $(if $(DRACUT_INIT), install, untagged)) + $(PACKER) build -only=base.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var-file=$(@D)/base.pkrvars.hcl \ + -var http_dir=$(@D)/http \ + -var output_directory=$(BUILDS)/$(@D)/base \ + -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ + -var vm_name=$(@D) \ + -var extra_ansible_args=-t,$(INIT_TAG) \ + ./ + $(HASHER) $(BUILDS)/$(@D)/base/$(@D) >$(BUILDS)/$(@D)/base/CHECKSUM # Provisioning images -$(PROVTARGETS): $(foreach flav, $(FLAVORS), %/$(flav)): %/base +$(PROVIMAGES) $(PROVTARGETS) $(REPROVTARGETS): - $(eval FLAVOR := $(basename $(@F))) - $(eval VERSION := $(if $(suffix $(@)), $(subst .,,$(suffix $(@))), 0)) - $(eval BASE_IMAGE := $(if $(wildcard $(@)/build/rootfs-image),\ - $(@)/build/rootfs-image,\ - $(@D)/base/rootfs-image)) - $(eval BUILD_DIR := $(@D)/$(FLAVOR).$(TIMESTAMP)) + $(eval FLAVOR := $(basename $(@F))) + $(eval ANSIBLE_DIR_PROV := $(if ansible-$(FLAVOR)/setup-$(FLAVOR).yml,\ + ansible-$(FLAVOR))) + $(eval VERSION := $(if $(suffix $(@)), $(subst .,,$(suffix $(@))), 0)) + $(eval BASE_IMAGE := $(if $(wildcard $(BUILDS)/$(@)/$(@D)-$(FLAVOR)),\ + $(BUILDS)/$(@)/$(@D)-$(FLAVOR),\ + $(BUILDS)/$(@D)/base/$(@D))) + $(eval BUILD_DIR := $(BUILDS)/$(@D)/$(FLAVOR).$(TIMESTAMP)) $(info ** Provisioning '$(@D)' with '$(FLAVOR)' **) @mkdir -p $(BUILD_DIR) @cp -r `readlink -f $(ANSIBLE_DIR_PROV)` $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) - @ln -sfn $(FLAVOR).$(TIMESTAMP) $(@D)/$(FLAVOR).latest + @ln -sfn $(FLAVOR).$(TIMESTAMP) $(BUILDS)/$(@D)/$(FLAVOR).latest @ln -sfr $(BUILD_DIR) $(dir $(BASE_IMAGE))/$(TIMESTAMP).backinglock - @-cp -r $@/$(ANSIBLE_DIR_PROV) $(BUILD_DIR)/$(ANSIBLE_DIR_PROV).$(VERSION) - @-cp -r $@/$(ANSIBLE_DIR_PROV).* $(BUILD_DIR) - $(PACKER) build -only=$(PROVISIONER) \ - $(PACKER_OPTS) \ - -var='vm_name=rootfs-image' \ - -var='output_directory=$(BUILD_DIR)/build' \ - -var='base_image=$(BASE_IMAGE)' \ - -var='playbook=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(FLAVOR).yml' \ - -var='extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS)' \ - ansible-provisioner.json + @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV) $(BUILD_DIR) + @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV).* $(BUILD_DIR) + $(PACKER) build -only=flavor.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var disk_image=true \ + -var iso_url=$(BASE_IMAGE) \ + -var iso_checksum=file:$(dir $(BASE_IMAGE))CHECKSUM \ + -var output_directory=$(BUILD_DIR)/image \ + -var playbook_file=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(FLAVOR).yml \ + -var vm_name=$(@D)-$(FLAVOR) \ + -var extra_ansible_args=$(ANSIBLE_PROV_EXT RA_ARGS) \ + ./ + $(HASHER) $(BUILD_DIR)/image/$(@D)-$(FLAVOR) \ + >$(BUILD_DIR)/image/CHECKSUM # Generating boot files $(BOOTTARGETS): %/boot: % $(BOOTTARGETS) $(CURBOOTTARGETS): - $(eval BASE_DIR := $(if $(filter base,$(notdir $(@D))),\ - ,\ - $(if $(wildcard $(@D)/build/.),\ - $(@D),\ - $(@D).$(TIMESTAMP)))) - $(eval BUILD_DIR := $(if $(BASE_DIR),\ - $(BASE_DIR)/build,\ - $(@D))) - $(eval BUILD_DIR := $(if $(filter $(@), $(CURBOOTTARGETS)),\ - $(BASE_DIR)/build,\ - $(BUILD_DIR))) - $(eval ANSIBLE_DIR_CUR := $(if $(BASE_DIR),\ - $(BASE_DIR)/$(ANSIBLE_DIR_PROV),\ - $(ANSIBLE_DIR_PROV))) + $(eval FLAVOR := $(notdir $(@D))) + $(eval BASE := $(patsubst %/, %, $(dir $(@D)))) + $(eval BASE_DIR := $(if $(filter base, $(notdir $(BUILDS)/$(@D))),\ + ,\ + $(if $(wildcard $(BUILDS)/$(@D)/image/.),\ + $(BUILDS)/$(@D),\ + $(BUILDS)/$(@D).$(TIMESTAMP)))) + $(eval BUILD_DIR := $(if $(BASE_DIR)/image,\ + $(BASE_DIR)/image,\ + $(BUILDS)/$(@D))) + $(eval BUILD_DIR := $(if $(filter $(@), $(CURBOOTTARGETS)),\ + $(BASE_DIR)/image,\ + $(BUILD_DIR))) $(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_CORE)/slx-builder.yml' \ - -var='extra_ansible_args=-t,install,-t,build' \ - -var='extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS)' \ - ansible-provisioner.json + $(PACKER) build -only=flavor.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var disk_image=true \ + -var iso_url=$(BUILD_DIR)/$(BASE)-$(FLAVOR) \ + -var iso_checksum=file:$(dir $(BUILD_DIR))image/CHECKSUM \ + -var output_directory=$(BUILD_DIR)/tmp \ + -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ + -var vm_name=$(BASE)-$(FLAVOR).tmp \ + -var extra_ansible_args=-t,install,-t,build \ + -var extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS) \ + ./ @mkdir -p $(BUILD_DIR)/boot - @mv -f $(ANSIBLE_DIR_CORE)/boot_files/* $(BUILD_DIR)/boot + @mv -f $(ANSIBLE_DIR_BOOT)/boot_files/* $(BUILD_DIR)/boot $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) - -$(COMPRESSTARGETS): - $(info ** Commiting and Compressing all changes to the image **) - $(eval IMAGE_NAME := $(@D)/build/rootfs-image) - @virt-sparsify --compress --verbose $(IMAGE_NAME) $(IMAGE_NAME).tmp - @rm -f $(IMAGE_NAME) - @mv $(IMAGE_NAME).tmp $(IMAGE_NAME) - - # Safe removal of images $(BASERMTARGETS): rm/%: %/*.backinglock @@ -227,9 +197,9 @@ rm/%: %/*.backinglock $(PROVRMTARGETS): rm/%: %/build/*.backinglock - $(eval BUILD_DIR := $(subst rm/,,$(@))/build) - $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-))) - $(eval BUILD_TIME := $(subst .,,$(suffix $(@)))) + $(eval BUILD_DIR := $(subst rm/,,$(@))/build) + $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-))) + $(eval BUILD_TIME := $(subst .,,$(suffix $(@)))) @rm -rf $(FATHER_BUILD)/$(BUILD_TIME).backinglock @rm -rf $(BUILD_DIR) @@ -244,78 +214,73 @@ backinglock: clean_except_last: @-$(foreach template,$(TEMPLATES),\ $(eval exclusions := $(shell test -d $(template) && \ - find $(template) \ - -maxdepth 1 \ - -type l \ - -print0 \ - | xargs -r -0 -n1 readlink))\ + find $(template) \ + -maxdepth 1 \ + -type l \ + -print0 \ + | xargs -r -0 -n1 readlink))\ test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - $(foreach file,$(exclusions),-not -name $(file) ) \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 rm -rf; ) - + find $(template)/* \ + -maxdepth 0 \ + -type d \ + $(foreach file,$(exclusions),-not -name $(file) ) \ + -not -name base \ + -print0 \ + | xargs -r -0 -n1 rm -rf; ) clean_failed: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 -i \ - $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"'; ) - + find $(template)/* \ + -maxdepth 0 \ + -type d \ + -not -name base \ + -print0 \ + | xargs -r -0 -n1 -i \ + $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"'; ) clean_bases: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && rm -rf $(template)/base;) - clean_all: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && rm -rf $(template);) - help: @printf "Usage:\n\tmake <template>/<flavor>[/boot]\n" - @echo - @echo "Base images targets:" + @printf "\n" + @printf "Base images targets:\n" @for T in $(BASETARGETS); do printf "\t%s\n" "$$T"; done - @echo - @echo "Provisioning images targets: " + @printf "\n" + @printf "Provisioning images targets:\n" @for P in $(PROVTARGETS); do printf "\t%s\n" "$$P"; done @for P in $(REPROVTARGETS); do printf "\t%s\n" "$$P"; done - @echo - @echo "Generate boot files targets:" + @printf "\n" + @printf "Generate boot files targets:\n" @printf "\t<{base,provisioning}_target>/boot\n" - @echo - @echo "Commiting backing files and Compressing targets:" + @printf "\n" + @printf "Commiting backing files and Compressing targets:" @for C in $(COMPRESSTARGETS); do printf "\t%s\n" "$$C"; done - @echo - @echo "For safely removing targets:" + @printf "\n" + @printf "For safely removing targets:\n" @printf "\trm/<target>\n" - @echo - @echo "Available options are:" - @printf "\tANSIBLE_DIR_CORE: Set directory with ansible roles for building initramfs (def: ansible-dracut)\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 "\n" + @printf "Available options are:\n" + @printf "\tANSIBLE_DIR_BOOT:\tSet directory with ansible roles for building initramfs (def: ansible-dracut)\n" + @printf "\tANSIBLE_DIR_PROV:\tSet directory with ansible roles for provisioning (def: ansible-roles-prov)\n" + @printf "\tDEBUG:\t\t\tEnable debug mode in packer (sets VERBOSE=1)\n" + @printf "\t\tDEBUG=1\t\tEnable enhanced on-error handling\n" + @printf "\t\tDEBUG=STEP\tEnable step by step debugging in packer\n" + @printf "\tFORCE=1:\t\tOverwrite existing builds\n" + @printf "\tPACKER:\t\t\tSet packer executable (def: packer)\n" + @printf "\tPACKER_OPTS:\t\tSet packer options\n" + @printf "\tVERBOSE=1:\t\tEnable verbose output\n" + @printf "\tWINDOW:\t\t\tDisable headless mode\n" + @printf "\tPKR_VAR_<VAR>=<VAL>:\tSet a packer variable <VAR>=<VAL>\n" + @printf "\tPKR_VAR_ssh_password='secret':\tDisable headless mode\n" + @printf "\n" + @printf "Clean targets are:\n" @printf "\tclean_except_last\n" @printf "\tclean_failed\n" @printf "\tclean_bases\n" diff --git a/hcl2/alma-8-x86_64/base.pkrvars.hcl b/alma-8-x86_64/base.pkrvars.hcl index 7178ea3..7178ea3 100644 --- a/hcl2/alma-8-x86_64/base.pkrvars.hcl +++ b/alma-8-x86_64/base.pkrvars.hcl diff --git a/hcl2/alma-8-x86_64/http/anaconda-ks.cfg b/alma-8-x86_64/http/anaconda-ks.cfg index 47ac4cd..47ac4cd 100644 --- a/hcl2/alma-8-x86_64/http/anaconda-ks.cfg +++ b/alma-8-x86_64/http/anaconda-ks.cfg diff --git a/hcl2/alma-9-x86_64/base.pkrvars.hcl b/alma-9-x86_64/base.pkrvars.hcl index ff70933..ff70933 100644 --- a/hcl2/alma-9-x86_64/base.pkrvars.hcl +++ b/alma-9-x86_64/base.pkrvars.hcl diff --git a/hcl2/alma-9-x86_64/http/anaconda-ks.cfg b/alma-9-x86_64/http/anaconda-ks.cfg index 47ac4cd..47ac4cd 100644 --- a/hcl2/alma-9-x86_64/http/anaconda-ks.cfg +++ b/alma-9-x86_64/http/anaconda-ks.cfg diff --git a/ansible-provisioner.json b/ansible-provisioner.json deleted file mode 100644 index 6ecd5e1..0000000 --- a/ansible-provisioner.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "variables": { - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [ - { - "type": "qemu", - "iso_url": "{{ user `base_image` }}", - "iso_checksum": "none", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "accelerator": "kvm", - "disk_image": "true", - "skip_compaction": "true", - "use_backing_file": "false", - "disk_size": "{{ user `disk_size` }}", - "format": "qcow2", - "headless": "{{ user `headless` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "systemctl poweroff", - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{ user `memory` }}"], - ["-smp", "{{ user `cpus` }}"] - ] - }, - { - "type": "virtualbox-ovf", - "source_path": "{{ user `base_image` }}.ovf", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "headless": "{{ user `headless` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "systemctl poweroff", - "guest_additions_mode": "disable", - "vboxmanage": [ - ["modifyvm", "{{ .Name }}", "--memory", "{{ user `memory` }}"], - ["modifyvm", "{{ .Name }}", "--cpus", "{{ user `cpus` }}"] - ] - } - ], - "provisioners": [{ - "type": "ansible", - "playbook_file": "{{ user `playbook` }}", - "extra_arguments": [ - "--ssh-extra-args", "-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa", - "--scp-extra-args", "\"-O\"" - ], - "sftp_command": "/usr/libexec/openssh/sftp-server", - "use_sftp": false - }] -} diff --git a/base.json b/base.json deleted file mode 100644 index 698d8f0..0000000 --- a/base.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "cpus": "2", - "disk_size": "5000", - "headless": "true", - "memory": "4096", - "ssh_timeout": "60m", - "ssh_username": "root" -} diff --git a/hcl2/base.pkr.hcl b/base.pkr.hcl index 0a7ec92..0a7ec92 100644 --- a/hcl2/base.pkr.hcl +++ b/base.pkr.hcl diff --git a/centos-7-x86_64.json b/centos-7-x86_64.json deleted file mode 100644 index 48be5b1..0000000 --- a/centos-7-x86_64.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "variables": { - "iso_base_url": "http://mirror2.hs-esslingen.de/centos/7/isos/x86_64", - "iso_url": "{{ user `iso_base_url` }}/CentOS-7-x86_64-NetInstall-2003.iso", - "iso_checksum_url": "{{ user `iso_base_url` }}/sha256sum.txt", - "iso_checksum_type": "sha256", - "vm_name": "centos-7-x86_64", - "boot_wait": "5s", - "http_dir": "http", - "kickstart_path": "centos-7/anaconda-ks.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_url` }}", - "iso_checksum_url": "{{ user `iso_checksum_url` }}", - "iso_checksum_type": "{{ user `iso_checksum_type` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "disk_size": "{{ user `disk_size` }}", - "format": "qcow2", - "disk_interface": "virtio-scsi", - "headless": "{{ user `headless` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_wait": "{{ user `boot_wait` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "qemuargs": [ - ["-m", "{{ user `memory` }}"], - ["-smp", "{{ user `cpus` }}"] - ], - "boot_command": [ - "<esc><wait>", - "linux inst.gpt biosdevname=0 net.ifnames=0 ", - "rootpw={{ user `ssh_password` }} ", - "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `kickstart_path` }}", - "<enter>" - ] - }], - "provisioners": [{ - "type": "ansible", - "playbook_file": "{{ user `playbook` }}", - "extra_arguments": "{{ user `extra_ansible_args` }}" - }] -} diff --git a/centos-8-x86_64.json b/centos-8-x86_64.json deleted file mode 100644 index 4d70f93..0000000 --- a/centos-8-x86_64.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "variables": { - "iso_url": "https://mirror1.hs-esslingen.de/pub/Mirrors/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso", - "iso_checksum": "https://mirror1.hs-esslingen.de/pub/Mirrors/centos/8-stream/isos/x86_64/CHECKSUM", - "vm_name": "centos-8-x86_64", - "boot_wait": "5s", - "http_dir": "http", - "kickstart_path": "centos-8/anaconda-ks.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_url` }}", - "iso_checksum": "file:{{ user `iso_checksum` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "format": "qcow2", - "disk_interface": "virtio-scsi", - "disk_size": "{{ user `disk_size` }}", - "headless": "{{ user `headless` }}", - "boot_wait": "{{ user `boot_wait` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_command": [ - "<esc><wait>", - "linux inst.gpt biosdevname=0 net.ifnames=0 ", - "rootpw={{ user `ssh_password` }} ", - "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `kickstart_path` }}", - "<enter>" - ], - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{ user `memory` }}"], - ["-smp", "{{ user `cpus` }}"] - ] - }], - "post-processors": [{ - "type": "manifest", - "output": "{{ user `output_directory` }}/manifest.json" - }] -} diff --git a/hcl2/centos-8-x86_64/base.pkrvars.hcl b/centos-8-x86_64/base.pkrvars.hcl index 8615dc8..8615dc8 100644 --- a/hcl2/centos-8-x86_64/base.pkrvars.hcl +++ b/centos-8-x86_64/base.pkrvars.hcl diff --git a/hcl2/centos-8-x86_64/http/anaconda-ks.cfg b/centos-8-x86_64/http/anaconda-ks.cfg index 7ca1731..7ca1731 100644 --- a/hcl2/centos-8-x86_64/http/anaconda-ks.cfg +++ b/centos-8-x86_64/http/anaconda-ks.cfg diff --git a/hcl2/centos-9-x86_64/base.pkrvars.hcl b/centos-9-x86_64/base.pkrvars.hcl index b342a37..b342a37 100644 --- a/hcl2/centos-9-x86_64/base.pkrvars.hcl +++ b/centos-9-x86_64/base.pkrvars.hcl diff --git a/hcl2/centos-9-x86_64/http/anaconda-ks.cfg b/centos-9-x86_64/http/anaconda-ks.cfg index 47ac4cd..47ac4cd 100644 --- a/hcl2/centos-9-x86_64/http/anaconda-ks.cfg +++ b/centos-9-x86_64/http/anaconda-ks.cfg diff --git a/debian-10.4-amd64.json b/debian-10.4-amd64.json deleted file mode 100644 index 26662ea..0000000 --- a/debian-10.4-amd64.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "variables": { - "iso_base_url": "https://ftp.fau.de/debian-cd/current/amd64/iso-cd", - "iso_checksum_type": "sha256", - "vm_name": "debian-10.4-amd64", - "http_dir": "http", - "preseed_path": "debian-10.4/preseed.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_base_url` }}/debian-10.4.0-amd64-netinst.iso", - "iso_checksum_url": "{{ user `iso_base_url` }}/SHA256SUMS", - "iso_checksum_type": "{{ user `iso_checksum_type` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "disk_size": "{{ user `disk_size` }}", - "format": "qcow2", - "headless": "{{ user `headless` }}", - "boot_wait": "5s", - "ssh_timeout": "{{user `ssh_timeout`}}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_command": [ - "<esc><wait>", - "install ", - "initrd=/install/initrd.gz ", - "auto=true ", - "passwd/root-password={{ user `ssh_password` }} ", - "passwd/root-password-again={{ user `ssh_password` }} ", - "debconf/priority=critical ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_path` }} ", - "<enter>" - ], - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{user `memory`}}"], - ["-smp", "{{user `cpus`}}"] - ] - }], - "provisioners": [{ - "type": "ansible", - "playbook_file": "{{ user `playbook` }}", - "extra_arguments": "{{ user `extra_ansible_args` }}" - }] -} diff --git a/hcl2/flavor.pkr.hcl b/flavor.pkr.hcl index 974bf32..974bf32 100644 --- a/hcl2/flavor.pkr.hcl +++ b/flavor.pkr.hcl diff --git a/hcl2/Makefile b/hcl2/Makefile deleted file mode 100644 index d5e0d30..0000000 --- a/hcl2/Makefile +++ /dev/null @@ -1,287 +0,0 @@ -# Simple Makefile to build base VM images using packer and ansible -# TODO -# * support ssh as user instead of root -# * testing target -PACKER ?= packer -ANSIBLE_DIR_BOOT ?= ansible-dracut -ANSIBLE_DIR_PROV ?= ansible-roles-prov -HASHER ?= sha256sum -SHELL := /usr/bin/env bash -BUILDS := builds - -ARCH := $(shell uname -m | sed 's/i686/i386/') - -AVAILABLE_BUILDERS := QEMU -BUILDER_QEMU_EXE := qemu-system-$(ARCH) -BUILDER_QEMU_NAME := qemu -BUILDER_QEMU_PROV := $(BUILDER_QEMU_NAME) - -BUILDERS := qemu - -override BUILDER := qemu -override PROVISIONER := qemu - -# The packer templates, detected as *.json (excluding base.json) -TEMPLATES := $(patsubst %/,%,$(dir $(wildcard */base.pkrvars.hcl))) - -# The provisioning flavors, detected as ansible-<flavor>/setup-<flavor>.yml -# Find all paths beginnig with "ansible-" and and save this suffix in PATTERNS -PATTERNS := $(patsubst ansible-%, %, $(wildcard ansible-*)) -# Extract <flavor> from ansible-<flavor>/setup-<flavor>.yml using PATTERNS as <flavor> -FLAVORS := $(foreach p, $(PATTERNS), \ - $(patsubst ansible-$(p)/setup-$(p).yml, $(p), \ - $(wildcard ansible-$(p)/setup-$(p).yml))) -# Extra flavor from variable ANSIBLE_DIR_PROV, using pattern ANSIBLE_DIR_PROV/setup-<flavor>.yml -FLAVORS += $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, \ - $(wildcard $(ANSIBLE_DIR_PROV)/setup-*.yml)) -FLAVORS := $(strip $(FLAVORS)) - -BASETARGETS := $(strip $(foreach t, $(TEMPLATES), $(t)/base)) -PROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ - $(foreach f, $(FLAVORS), $(t)/$(f)))) -PROVIMAGES := $(strip $(foreach f, $(FLAVORS), \ - $(foreach t, $(TEMPLATES), $(t)/$(f): %/$(f): %/base))) -REPROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ - $(foreach f, $(FLAVORS), \ - $(filter-out $(t)/$(f).latest, \ - $(wildcard $(t)/$(f).*))))) -COMPRESSPOSSIBLE := $(foreach t, $(TEMPLATES), \ - $(foreach f, $(FLAVORS), $(wildcard $(t)/$(f).*))) -COMPRESSTARGETS := $(foreach p, $(COMPRESSPOSSIBLE), $(p)/compress) -BOOTTARGETS := $(foreach t, $(TEMPLATES), $(t)/base/boot) -BOOTTARGETS += $(foreach p, $(PROVTARGETS), $(p)/boot) -BOOTTARGETS := $(strip $(BOOTTARGETS)) -CURBOOTTARGETS := $(foreach p, $(REPROVTARGETS), $(p)/boot) -BASERMTARGETS := $(foreach t, $(BASETARGETS), rm/$(t)) -PROVRMTARGETS := $(foreach t, $(REPROVTARGETS), rm/$(t)) - -ifndef ANSIBLE_PROV_EXTRA_ARGS - ANSIBLE_PROV_EXTRA_ARGS := -endif - -ifdef DEBUG - VERBOSE := 1 - ifeq ($(DEBUG),STEP) - override PACKER_OPTS += -debug - else - override PACKER_OPTS += -on-error=ask - endif -endif - -ifdef FORCE - override PACKER_OPTS += -force -endif - -ifdef WINDOW - override PACKER_OPTS += -var headless=false -endif - -override PACKER_OPTS += -warn-on-undeclared-var - -# We support parallel Provisioning packer builds. -# To ensure data consistency we save the used ansible roles before executing in -# its own environment, tagged by the current date & time. -TIMESTAMP := $(shell date "+%Y-%m-%d_%H-%M-%S") - -ifdef VERBOSE - $(info timestamp: $(TIMESTAMP)) - $(info ) - $(info packer: executable: $(PACKER)) - $(info packer: options: $(PACKER_OPTS)) - $(info hasher: $(HASHER)) - $(info ) - $(info ansible: boot: $(ANSIBLE_DIR_BOOT)) - $(info ansible: flavors: $(FLAVORS)) - $(info ) - $(info builder: available: $(AVAILABLE_BUILDERS)) - $(info builder: chosen: $(BUILDER)) - $(info ) - $(info targets: base: $(BASETARGETS)) - $(info targets: boot: $(BOOTTARGETS)) - $(info targets: provision: $(PROVTARGETS)) - $(info targets: reprovision: $(REPROVTARGETS)) - $(info ) - override PACKER := PACKER_LOG=1 $(PACKER) -endif - -.PHONY: help clean_except_last clean_bases clean_all clean_failed backinglock $(REPROVTARGETS) -help: - -# Creating base images. When DRACUT_INIT is specified, the dracut module -# repository will be initially cloned and its required components (dnbd3, -# xmount, libxmount-qemu) will be pre-build to accelerate subsequent builds. -$(BASETARGETS): - $(info ** Building template '$(@D)' using '$(BUILDER)' **) - $(eval INIT_TAG := $(if $(DRACUT_INIT), install, untagged)) - $(PACKER) build -only=base.$(BUILDER).ansible \ - $(PACKER_OPTS) \ - -var-file=$(@D)/base.pkrvars.hcl \ - -var http_dir=$(@D)/http \ - -var output_directory=$(BUILDS)/$(@D)/base \ - -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ - -var vm_name=$(@D) \ - -var extra_ansible_args=-t,$(INIT_TAG) \ - ./ - $(HASHER) $(BUILDS)/$(@D)/base/$(@D) >$(BUILDS)/$(@D)/base/CHECKSUM - -# Provisioning images -$(PROVIMAGES) - -$(PROVTARGETS) $(REPROVTARGETS): - $(eval FLAVOR := $(basename $(@F))) - $(eval ANSIBLE_DIR_PROV := $(if ansible-$(FLAVOR)/setup-$(FLAVOR).yml,\ - ansible-$(FLAVOR))) - $(eval VERSION := $(if $(suffix $(@)), $(subst .,,$(suffix $(@))), 0)) - $(eval BASE_IMAGE := $(if $(wildcard $(BUILDS)/$(@)/$(@D)-$(FLAVOR)),\ - $(BUILDS)/$(@)/$(@D)-$(FLAVOR),\ - $(BUILDS)/$(@D)/base/$(@D))) - $(eval BUILD_DIR := $(BUILDS)/$(@D)/$(FLAVOR).$(TIMESTAMP)) - $(info ** Provisioning '$(@D)' with '$(FLAVOR)' **) - @mkdir -p $(BUILD_DIR) - @cp -r `readlink -f $(ANSIBLE_DIR_PROV)` $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) - @ln -sfn $(FLAVOR).$(TIMESTAMP) $(BUILDS)/$(@D)/$(FLAVOR).latest - @ln -sfr $(BUILD_DIR) $(dir $(BASE_IMAGE))/$(TIMESTAMP).backinglock - @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV) $(BUILD_DIR) - @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV).* $(BUILD_DIR) - $(PACKER) build -only=flavor.$(BUILDER).ansible \ - $(PACKER_OPTS) \ - -var disk_image=true \ - -var iso_url=$(BASE_IMAGE) \ - -var iso_checksum=file:$(dir $(BASE_IMAGE))CHECKSUM \ - -var output_directory=$(BUILD_DIR)/image \ - -var playbook_file=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(FLAVOR).yml \ - -var vm_name=$(@D)-$(FLAVOR) \ - -var extra_ansible_args=$(ANSIBLE_PROV_EXT RA_ARGS) \ - ./ - $(HASHER) $(BUILD_DIR)/image/$(@D)-$(FLAVOR) \ - >$(BUILD_DIR)/image/CHECKSUM - -# Generating boot files -$(BOOTTARGETS): %/boot: % - -$(BOOTTARGETS) $(CURBOOTTARGETS): - $(eval FLAVOR := $(notdir $(@D))) - $(eval BASE := $(patsubst %/, %, $(dir $(@D)))) - $(eval BASE_DIR := $(if $(filter base, $(notdir $(BUILDS)/$(@D))),\ - ,\ - $(if $(wildcard $(BUILDS)/$(@D)/image/.),\ - $(BUILDS)/$(@D),\ - $(BUILDS)/$(@D).$(TIMESTAMP)))) - $(eval BUILD_DIR := $(if $(BASE_DIR)/image,\ - $(BASE_DIR)/image,\ - $(BUILDS)/$(@D))) - $(eval BUILD_DIR := $(if $(filter $(@), $(CURBOOTTARGETS)),\ - $(BASE_DIR)/image,\ - $(BUILD_DIR))) - $(info ** Generating boot files for '$(BUILD_DIR)') - $(PACKER) build -only=flavor.$(BUILDER).ansible \ - $(PACKER_OPTS) \ - -var disk_image=true \ - -var iso_url=$(BUILD_DIR)/$(BASE)-$(FLAVOR) \ - -var iso_checksum=file:$(dir $(BUILD_DIR))image/CHECKSUM \ - -var output_directory=$(BUILD_DIR)/tmp \ - -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ - -var vm_name=$(BASE)-$(FLAVOR).tmp \ - -var extra_ansible_args=-t,install,-t,build \ - -var extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS) \ - ./ - @mkdir -p $(BUILD_DIR)/boot - @mv -f $(ANSIBLE_DIR_BOOT)/boot_files/* $(BUILD_DIR)/boot - $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) - -# Safe removal of images -$(BASERMTARGETS): -rm/%: %/*.backinglock - $(eval BUILD_DIR := $(subst rm/,,$(@))) - @rm -rf $(BUILD_DIR) - -$(PROVRMTARGETS): -rm/%: %/build/*.backinglock - $(eval BUILD_DIR := $(subst rm/,,$(@))/build) - $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-))) - $(eval BUILD_TIME := $(subst .,,$(suffix $(@)))) - @rm -rf $(FATHER_BUILD)/$(BUILD_TIME).backinglock - @rm -rf $(BUILD_DIR) - -%.backinglock: backinglock - @qemu-img convert -f qcow2 $(@)/build/rootfs-image -O qcow2 $(@)/build/rootfs-image.tmp - @rm $(@)/build/rootfs-image - @mv $(@)/build/rootfs-image.tmp $(@)/build/rootfs-image - @rm $(@) - -backinglock: - -clean_except_last: - @-$(foreach template,$(TEMPLATES),\ - $(eval exclusions := $(shell test -d $(template) && \ - find $(template) \ - -maxdepth 1 \ - -type l \ - -print0 \ - | xargs -r -0 -n1 readlink))\ - test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - $(foreach file,$(exclusions),-not -name $(file) ) \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 rm -rf; ) - -clean_failed: - @-$(foreach template,$(TEMPLATES),\ - test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 -i \ - $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"'; ) - -clean_bases: - @-$(foreach template,$(TEMPLATES),\ - test -d $(template) && rm -rf $(template)/base;) - -clean_all: - @-$(foreach template,$(TEMPLATES),\ - test -d $(template) && rm -rf $(template);) - -help: - @printf "Usage:\n\tmake <template>/<flavor>[/boot]\n" - @printf "\n" - @printf "Base images targets:\n" - @for T in $(BASETARGETS); do printf "\t%s\n" "$$T"; done - @printf "\n" - @printf "Provisioning images targets:\n" - @for P in $(PROVTARGETS); do printf "\t%s\n" "$$P"; done - @for P in $(REPROVTARGETS); do printf "\t%s\n" "$$P"; done - @printf "\n" - @printf "Generate boot files targets:\n" - @printf "\t<{base,provisioning}_target>/boot\n" - @printf "\n" - @printf "Commiting backing files and Compressing targets:" - @for C in $(COMPRESSTARGETS); do printf "\t%s\n" "$$C"; done - @printf "\n" - @printf "For safely removing targets:\n" - @printf "\trm/<target>\n" - @printf "\n" - @printf "Available options are:\n" - @printf "\tANSIBLE_DIR_BOOT:\tSet directory with ansible roles for building initramfs (def: ansible-dracut)\n" - @printf "\tANSIBLE_DIR_PROV:\tSet directory with ansible roles for provisioning (def: ansible-roles-prov)\n" - @printf "\tDEBUG:\t\t\tEnable debug mode in packer (sets VERBOSE=1)\n" - @printf "\t\tDEBUG=1\t\tEnable enhanced on-error handling\n" - @printf "\t\tDEBUG=STEP\tEnable step by step debugging in packer\n" - @printf "\tFORCE=1:\t\tOverwrite existing builds\n" - @printf "\tPACKER:\t\t\tSet packer executable (def: packer)\n" - @printf "\tPACKER_OPTS:\t\tSet packer options\n" - @printf "\tVERBOSE=1:\t\tEnable verbose output\n" - @printf "\tWINDOW:\t\t\tDisable headless mode\n" - @printf "\tPKR_VAR_<VAR>=<VAL>:\tSet a packer variable <VAR>=<VAL>\n" - @printf "\tPKR_VAR_ssh_password='secret':\tDisable headless mode\n" - @printf "\n" - @printf "Clean targets are:\n" - @printf "\tclean_except_last\n" - @printf "\tclean_failed\n" - @printf "\tclean_bases\n" - @printf "\tclean_all\n" diff --git a/http/centos-7 b/http/centos-7 deleted file mode 120000 index 95e1895..0000000 --- a/http/centos-7 +++ /dev/null @@ -1 +0,0 @@ -centos
\ No newline at end of file diff --git a/http/centos-8/anaconda-ks.cfg b/http/centos-8/anaconda-ks.cfg deleted file mode 100644 index 236870a..0000000 --- a/http/centos-8/anaconda-ks.cfg +++ /dev/null @@ -1,51 +0,0 @@ - -#Deprecated functions since centOs 7 -#https://docs.centos.org/en-US/8-docs/advanced-install/assembly_kickstart-commands-and-options-reference/#kickstart-changes_kickstart-commands-and-options-reference - -text -reboot -url --mirrorlist=http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=baseos -lang en_US.UTF-8 -keyboard --vckeymap=us --xlayouts='us' -timezone Europe/Berlin --isUtc --nontp -clearpart --none --initlabel -bootloader --location=mbr --boot-drive=sda -part biosboot --fstype="biosboot" --ondisk=sda --size=1 -part / --fstype="xfs" --ondisk=sda --grow --label=SLX_SYS - -%packages -@^minimal-environment -%end - -# small python script to extract the password from the kernel command line -# expects the password given as: rootpw=<password> -%pre --interpreter=/usr/libexec/platform-python -import shlex, crypt -arg = 'rootpw=' -with open('/proc/cmdline', 'r') as f: - kcl = f.read().split() -# extract the password -passwords = [x[len(arg):] for x in kcl if x.startswith(arg)] -if len(passwords) == 1: - kclpass = passwords[0] -# TODO sane fallbacks. This should work most of the time though :) -# generate SHA512 hash -hash = crypt.crypt(kclpass, crypt.mksalt(crypt.METHOD_SHA512)) -with open('/tmp/setup-root-pass', 'w') as f: - f.write('rootpw --iscrypted ' + hash) -%end -# include the created password file -%include /tmp/setup-root-pass - -%post --erroronfail -# allow root login for ansible -sed 's,^[[:blank:]]*#*PermitRootLogin.*,PermitRootLogin yes,g' /etc/ssh/sshd_config - -ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -EOF -%end diff --git a/http/centos/anaconda-ks.cfg b/http/centos/anaconda-ks.cfg deleted file mode 100644 index 71303e7..0000000 --- a/http/centos/anaconda-ks.cfg +++ /dev/null @@ -1,51 +0,0 @@ -install -text -reboot -url --mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os -lang en_US.UTF-8 -keyboard --vckeymap=us --xlayouts='us' -timezone Europe/Berlin --isUtc --nontp -auth --enableshadow --passalgo=sha512 -clearpart --none --initlabel -bootloader --location=mbr --boot-drive=sda -part biosboot --fstype="biosboot" --ondisk=sda --size=1 -part / --fstype="xfs" --ondisk=sda --grow --label=SLX_SYS - -%packages -@^minimal -@core -%end - -# small python script to extract the password from the kernel command line -# expects the password given as: rootpw=<password> -%pre --interpreter=/usr/libexec/platform-python -import shlex, crypt -arg = 'rootpw=' -with open('/proc/cmdline', 'r') as f: - kcl = f.read().split() -# extract the password -passwords = [x[len(arg):] for x in kcl if x.startswith(arg)] -if len(passwords) == 1: - kclpass = passwords[0] -# TODO sane fallbacks. This should work most of the time though :) -# generate SHA512 hash -hash = crypt.crypt(kclpass, crypt.mksalt(crypt.METHOD_SHA512)) -with open('/tmp/setup-root-pass', 'w') as f: - f.write('rootpw --iscrypted ' + hash) -%end -# include the created password file -%include /tmp/setup-root-pass - -%post --erroronfail -# allow root login for ansible -sed 's,^[[:blank:]]*#*PermitRootLogin.*,PermitRootLogin yes,g' /etc/ssh/sshd_config - -# enable dhcp on main network interface for subsequent packer runs -ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -EOF -%end diff --git a/http/debian-10.4 b/http/debian-10.4 deleted file mode 120000 index b2f7fd3..0000000 --- a/http/debian-10.4 +++ /dev/null @@ -1 +0,0 @@ -debian
\ No newline at end of file diff --git a/http/debian/preseed.cfg b/http/debian/preseed.cfg deleted file mode 100644 index 749dd61..0000000 --- a/http/debian/preseed.cfg +++ /dev/null @@ -1,63 +0,0 @@ -d-i debian-installer/locale string en_US -d-i time/zone string Europe/Berlin -d-i keyboard-configuration/xkb-keymap select de - -d-i mirror/country string manual -d-i mirror/http/hostname string ftp.de.debian.org -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string -d-i mirror/http/mirror select ftp.de.debian.org - -d-i partman-basicfilesystems/choose_label string gpt -d-i partman-basicfilesystems/default_label string gpt -d-i partman-basicfilesystems/no_swap boolean false -d-i partman-partitioning/choose_label string gpt -d-i partman-partitioning/default_label string gpt -d-i partman/choose_label string gpt -d-i partman/default_label string gpt -d-i partman-swapfile/size string 0 -d-i partman-auto/disk string /dev/vda -d-i partman-auto/method string regular -d-i partman-auto/expert_recipe string \ - scheme :: \ - 32 32 32 free \ - $gptonly{ } \ - $primary{ } \ - $bios_boot{ } \ - method{ biosgrub } . \ - 1 0 -1 ext4 \ - $gptonly{ } \ - $primary{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - label{ SLX_SYS } \ - mountpoint{ / } . -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -d-i base-installer/excludes string laptop-detect -d-i passwd/make-user boolean false -d-i passwd/root-login boolean true -d-i user-setup/allow-password-weak boolean true - -## install base packages ## -d-i pkgsel/include string openssh-server -d-i preseed/early_command string \ - mkdir -p /usr/lib/post-base-installer.d && \ - echo "sed -i -e 's/^in-target.*tasksel.*/#\\0/' /var/lib/dpkg/info/pkgsel.postinst" > /usr/lib/post-base-installer.d/90skip-tasksel && \ - chmod +x /usr/lib/post-base-installer.d/90skip-tasksel - -d-i preseed/late_command string \ - in-target sed -i 's,^[# \t]*PermitRootLogin.*,PermitRootLogin yes,' /etc/ssh/sshd_config ; \ - in-target apt-get update ; \ - in-target apt-get -y upgrade - -d-i grub-installer/bootdev string /dev/vda -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean true - -d-i finish-install/reboot_in_progress note diff --git a/http/rocky-8 b/http/rocky-8 deleted file mode 120000 index c8dbb8c..0000000 --- a/http/rocky-8 +++ /dev/null @@ -1 +0,0 @@ -rocky
\ No newline at end of file diff --git a/http/rocky-9 b/http/rocky-9 deleted file mode 120000 index c8dbb8c..0000000 --- a/http/rocky-9 +++ /dev/null @@ -1 +0,0 @@ -rocky
\ No newline at end of file diff --git a/http/rocky/anaconda-ks.cfg b/http/rocky/anaconda-ks.cfg deleted file mode 100644 index 3800771..0000000 --- a/http/rocky/anaconda-ks.cfg +++ /dev/null @@ -1,104 +0,0 @@ -# install -# text -# reboot -# # url --mirrorlist="https://mirrors.rockylinux.org/metalink?repo=rocky-$releasever&arch=$basearch" -# # url --url="https://ftp.gwdg.de/pub/linux/rocky/$releasever/Minimal/$basearch/os/" -# lang en_US.UTF-8 -# keyboard --vckeymap=us --xlayouts='us' -# timezone Europe/Berlin --isUtc --nontp -# auth --enableshadow --passalgo=sha512 -# clearpart --none --initlabel -# bootloader --location=mbr --boot-drive=sda -# part biosboot --fstype="biosboot" --ondisk=sda --size=1 -# part / --fstype="ext4" --ondisk=sda --grow --label=SLX_SYS - - -# url --mirrorlist="https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch" -clearpart --none --initlabel -bootloader --location=mbr --boot-drive=sda -part biosboot --fstype=biosboot --ondisk=sda --size=1 -part / --fstype=xfs --asprimary --ondisk=sda --grow --label=SLX_SYS -lang en_US.UTF-8 -keyboard --vckeymap=us --xlayouts='us' -timezone Europe/Berlin --isUtc --nontp -text -reboot - - -%packages -@core -%end - -%pre --interpreter=/usr/bin/perl -use strict; -use warnings; -use feature 'say'; - -open(my $fp, '<', '/proc/cmdline') or die $!; -chomp(my $line = scalar <$fp>); -close($fp); - -my @tokens = map {/^rootpw=(.*)/ ? $1 : () } - split / /, $line; - -exit if @tokens < 1; - -my $pw = crypt($tokens[0], "\$6\$1U9v8hxj6xmYNJBA\$"); - -open($fp, '>', '/tmp/setup-root-pass') or die $!; -say $fp "rootpw --iscrypted $pw"; -close($fp); -%end - -# small python script to extract the password from the kernel command line -# expects the password given as: rootpw=<password> -# %pre --interpreter=/usr/bin/python -# import shlex, crypt -# arg = 'rootpw=' -# with open('/proc/cmdline', 'r') as f: -# kcl = f.read().split() -# # extract the password -# passwords = [x[len(arg):] for x in kcl if x.startswith(arg)] -# if len(passwords) == 1: -# kclpass = passwords[0] -# # TODO sane fallbacks. This should work most of the time though :) -# # generate SHA512 hash -# hash = crypt.crypt(kclpass, crypt.mksalt(crypt.METHOD_SHA512)) -# with open('/tmp/setup-root-pass', 'w') as f: -# f.write('rootpw --iscrypted ' + hash) -# %end -# include the created password file -%include /tmp/setup-root-pass - -%post --erroronfail -set -x -parted -s /dev/sda -- name 2 SLX_SYS -# rpm --import 'https://www.elrepo.org/RPM-GPG-KEY-elrepo.org' -# yum -y install 'http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm' -# yum-config-manager --enable elrepo-kernel -# yum -y makecache -# yum -y install kernel-ml kernel-ml-devel kernel-ml-headers -# sed -i 's,^GRUB_DEFAULT=.*$,GRUB_DEFAULT=0,' /etc/default/grub -# grub2-mkconfig -o /boot/grub2/grub.cfg -# dnf -y install epel-release -# -dnf -y install epel-release -dnf -y update -dnf -y install curl git python3 vim wget -#dnf -y install atop git htop iftop jq mutt nmap nmap-ncat systemd-networkd tcpdump vim wget -dnf clean all -#systemctl enable sshd -#alternatives --set python /usr/bin/python3 - -# allow root login for ansible -sed -i 's,^[[:blank:]]*#*PermitRootLogin.*,PermitRootLogin yes,g' /etc/ssh/sshd_config - -ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -EOF -set +x -%end diff --git a/http/ubuntu-18.04 b/http/ubuntu-18.04 deleted file mode 120000 index 7d13753..0000000 --- a/http/ubuntu-18.04 +++ /dev/null @@ -1 +0,0 @@ -ubuntu
\ No newline at end of file diff --git a/http/ubuntu/preseed.cfg b/http/ubuntu/preseed.cfg deleted file mode 100644 index b2b7023..0000000 --- a/http/ubuntu/preseed.cfg +++ /dev/null @@ -1,63 +0,0 @@ -d-i debian-installer/locale string en_US -d-i time/zone string Europe/Berlin -d-i keyboard-configuration/xkb-keymap select de - -d-i mirror/country string manual -d-i mirror/http/hostname string de.archive.ubuntu.com -d-i mirror/http/directory string /ubuntu -d-i mirror/http/proxy string -d-i mirror/http/mirror select de.archive.ubuntu.com - -d-i partman-basicfilesystems/choose_label string gpt -d-i partman-basicfilesystems/default_label string gpt -d-i partman-basicfilesystems/no_swap boolean false -d-i partman-partitioning/choose_label string gpt -d-i partman-partitioning/default_label string gpt -d-i partman/choose_label string gpt -d-i partman/default_label string gpt -d-i partman-swapfile/size string 0 -d-i partman-auto/disk string /dev/vda -d-i partman-auto/method string regular -d-i partman-auto/expert_recipe string \ - scheme :: \ - 32 32 32 free \ - $gptonly{ } \ - $primary{ } \ - $bios_boot{ } \ - method{ biosgrub } . \ - 1 0 -1 ext4 \ - $gptonly{ } \ - $primary{ } \ - method{ format } \ - format{ } \ - use_filesystem{ } \ - filesystem{ ext4 } \ - label{ SLX_SYS } \ - mountpoint{ / } . -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -d-i base-installer/excludes string laptop-detect -d-i passwd/make-user boolean false -d-i passwd/root-login boolean true -d-i user-setup/allow-password-weak boolean true - -## install base packages ## -d-i pkgsel/include string openssh-server -d-i preseed/early_command string \ - mkdir -p /usr/lib/post-base-installer.d && \ - echo "sed -i -e 's/^in-target.*tasksel.*/#\\0/' /var/lib/dpkg/info/pkgsel.postinst" > /usr/lib/post-base-installer.d/90skip-tasksel && \ - chmod +x /usr/lib/post-base-installer.d/90skip-tasksel - -d-i preseed/late_command string \ - in-target sed -i 's,^[# \t]*PermitRootLogin.*,PermitRootLogin yes,' /etc/ssh/sshd_config ; \ - in-target apt-get update ; \ - in-target apt-get -y upgrade - -d-i grub-installer/bootdev string /dev/vda -d-i grub-installer/only_debian boolean true -d-i grub-installer/with_other_os boolean true - -d-i finish-install/reboot_in_progress note diff --git a/rocky-8-x86_64.json b/rocky-8-x86_64.json deleted file mode 100644 index 7b39b02..0000000 --- a/rocky-8-x86_64.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "variables": { - "iso_url": "https://mirror1.hs-esslingen.de/pub/Mirrors/rocky/8/isos/x86_64/Rocky-x86_64-minimal.iso", - "iso_checksum": "https://mirror1.hs-esslingen.de/pub/Mirrors/rocky/8/isos/x86_64/CHECKSUM", - "vm_name": "rocky-9-x86_64", - "boot_wait": "5s", - "http_dir": "http", - "kickstart_path": "rocky-8/anaconda-ks.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_url` }}", - "iso_checksum": "file:{{ user `iso_checksum` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "format": "qcow2", - "disk_interface": "virtio-scsi", - "disk_size": "{{ user `disk_size` }}", - "headless": "{{ user `headless` }}", - "boot_wait": "{{ user `boot_wait` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_command": [ - "<esc><wait>", - "linux inst.gpt biosdevname=0 net.ifnames=0 ", - "rootpw={{ user `ssh_password` }} ", - "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `kickstart_path` }}", - "<enter>" - ], - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{ user `memory` }}"], - ["-smp", "{{ user `cpus` }}"] - ] - }], - "post-processors": [{ - "type": "manifest", - "output": "{{ user `output_directory` }}/manifest.json" - }] -} diff --git a/hcl2/rocky-8-x86_64/base.pkrvars.hcl b/rocky-8-x86_64/base.pkrvars.hcl index 7c9e283..7c9e283 100644 --- a/hcl2/rocky-8-x86_64/base.pkrvars.hcl +++ b/rocky-8-x86_64/base.pkrvars.hcl diff --git a/hcl2/rocky-8-x86_64/http/anaconda-ks.cfg b/rocky-8-x86_64/http/anaconda-ks.cfg index 47ac4cd..47ac4cd 100644 --- a/hcl2/rocky-8-x86_64/http/anaconda-ks.cfg +++ b/rocky-8-x86_64/http/anaconda-ks.cfg diff --git a/rocky-9-x86_64.json b/rocky-9-x86_64.json deleted file mode 100644 index da2aeae..0000000 --- a/rocky-9-x86_64.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "variables": { - "iso_url": "https://mirror1.hs-esslingen.de/pub/Mirrors/rocky/9/isos/x86_64/Rocky-9-latest-x86_64-minimal.iso", - "iso_checksum": "https://mirror1.hs-esslingen.de/pub/Mirrors/rocky/9/isos/x86_64/CHECKSUM", - "vm_name": "rocky-9-x86_64", - "boot_wait": "5s", - "http_dir": "http", - "kickstart_path": "rocky-9/anaconda-ks.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_url` }}", - "iso_checksum": "file:{{ user `iso_checksum` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "format": "qcow2", - "disk_interface": "virtio-scsi", - "disk_size": "{{ user `disk_size` }}", - "headless": "{{ user `headless` }}", - "boot_wait": "{{ user `boot_wait` }}", - "ssh_timeout": "{{ user `ssh_timeout` }}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_command": [ - "<esc><wait>", - "linux inst.cmdline biosdevname=0 net.ifnames=0 ", - "rootpw={{ user `ssh_password` }} ", - "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `kickstart_path` }}", - "<enter>" - ], - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{ user `memory` }}"], - ["-smp", "{{ user `cpus` }}"] - ] - }], - "post-processors": [{ - "type": "manifest", - "output": "{{ user `output_directory` }}/manifest.json" - }] -} diff --git a/hcl2/rocky-9-x86_64/base.pkrvars.hcl b/rocky-9-x86_64/base.pkrvars.hcl index 9406323..9406323 100644 --- a/hcl2/rocky-9-x86_64/base.pkrvars.hcl +++ b/rocky-9-x86_64/base.pkrvars.hcl diff --git a/hcl2/rocky-9-x86_64/http/anaconda-ks.cfg b/rocky-9-x86_64/http/anaconda-ks.cfg index 47ac4cd..47ac4cd 100644 --- a/hcl2/rocky-9-x86_64/http/anaconda-ks.cfg +++ b/rocky-9-x86_64/http/anaconda-ks.cfg diff --git a/hcl2/source.pkr.hcl b/source.pkr.hcl index 34c1d2e..34c1d2e 100644 --- a/hcl2/source.pkr.hcl +++ b/source.pkr.hcl diff --git a/ubuntu-18.04-amd64.json b/ubuntu-18.04-amd64.json deleted file mode 100644 index 6697450..0000000 --- a/ubuntu-18.04-amd64.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "variables": { - "iso_base_url": "http://cdimage.ubuntu.com/releases/18.04/release", - "iso_checksum_type": "sha256", - "vm_name": "ubuntu-18.04-amd64", - "http_dir": "http", - "preseed_path": "ubuntu-18.04/preseed.cfg", - "shutdown_command": "systemctl poweroff", - "ssh_password": "{{ env `ROOTPW` }}" - }, - "builders": [{ - "type": "qemu", - "accelerator": "kvm", - "iso_url": "{{ user `iso_base_url` }}/ubuntu-18.04.4-server-amd64.iso", - "iso_checksum_url": "{{ user `iso_base_url` }}/SHA256SUMS", - "iso_checksum_type": "{{ user `iso_checksum_type` }}", - "output_directory": "{{ user `output_directory` }}", - "vm_name": "{{ user `vm_name` }}", - "disk_size": "{{ user `disk_size` }}", - "format": "qcow2", - "headless": "{{ user `headless` }}", - "boot_wait": "5s", - "ssh_timeout": "{{user `ssh_timeout`}}", - "ssh_username": "{{ user `ssh_username` }}", - "ssh_password": "{{ user `ssh_password` }}", - "shutdown_command": "{{ user `shutdown_command` }}", - "http_directory": "{{ user `http_dir` }}", - "boot_command": [ - "<esc><wait>", - "<esc><wait>", - "<enter><wait>", - "/install/vmlinuz ", - "initrd=/install/initrd.gz ", - "auto=true ", - "passwd/root-password={{ user `ssh_password` }} ", - "passwd/root-password-again={{ user `ssh_password` }} ", - "debconf/priority=critical ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{ user `preseed_path` }} ", - "<enter>" - ], - "qemuargs": [ - ["-cpu", "host"], - ["-m", "{{user `memory`}}"], - ["-smp", "{{user `cpus`}}"] - ] - }], - "provisioners": [{ - "type": "ansible", - "playbook_file": "{{ user `playbook` }}", - "extra_arguments": "{{ user `extra_ansible_args` }}" - }] -} diff --git a/hcl2/variables.pkr.hcl b/variables.pkr.hcl index 1c49a48..1c49a48 100644 --- a/hcl2/variables.pkr.hcl +++ b/variables.pkr.hcl |