From d28214fc5054199efa2046ed95c5e4e891c6b521 Mon Sep 17 00:00:00 2001 From: Jake Buchholz Date: Thu, 30 May 2019 21:04:11 -0700 Subject: simple updates... * .gitignore - don't ignore whole dirs and then opt-in specific files * Makefile - fail if required vars aren't set - SCRIPTS --> ALL_SCRIPTS * profiles/README.md - variables.yaml --> vars.json - drop 'not possible to add/modify/remove arbitrary files' comment * make-amis - use -eq for integer comparison - make shellcheck happier with printf's - remove old bad-idea TODO --- .gitignore | 11 ----------- Makefile | 9 ++++++++- profiles/README.md | 7 +------ scripts/make-amis | 8 +++----- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 89f22ab..ff26dbe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,14 +2,3 @@ **/*.bak **/*.swp /build/ -/profiles/* -!/profiles/README.md -!/profiles/base/ -!/profiles/arch/ -!/profiles/version/ -!/profiles/alpine.conf -!/profiles/example.conf -!/profiles/test.conf -/releases/* -!/releases/README.md -!/releases/alpine.yaml diff --git a/Makefile b/Makefile index 626f6c8..8247c9b 100644 --- a/Makefile +++ b/Makefile @@ -12,18 +12,24 @@ LEVEL := PACKER := packer export PACKER +require_var = $(if $(value $1),,$(error $1=... required)) + .PHONY: amis prune release-readme clean amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py + @:$(call require_var, PROFILE) build/make-amis $(PROFILE) $(BUILDS) prune: build build/prune-amis.py + @:$(call require_var, LEVEL) + @:$(call require_var, PROFILE) build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD) release-readme: build build/gen-release-readme.py + @:$(call require_var, PROFILE) build/gen-release-readme.py $(PROFILE) -build: $(SCRIPTS) +build: $(ALL_SCRIPTS) [ -d build/profile ] || mkdir -p build/profile python3 -m venv build/.py3 build/.py3/bin/pip install pyhocon pyyaml boto3 @@ -33,6 +39,7 @@ build/packer.json: build packer.conf build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) + @:$(call require_var, PROFILE) build/resolve-profile.py $(PROFILE) %.py: %.py.in build diff --git a/profiles/README.md b/profiles/README.md index 107b59e..2dfd50e 100644 --- a/profiles/README.md +++ b/profiles/README.md @@ -1,7 +1,7 @@ # Profiles Profiles are collections of related build definitions, which are used to -generate the `variables.yaml` files that [Packer](https://packer.io) consumes +generate the `vars.json` files that [Packer](https://packer.io) consumes when building AMIs. Profiles use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md) @@ -150,8 +150,3 @@ ami_access { * The AMI's login user is currently hard coded to be `alpine`. Changes to [tiny-ec2-bootstrap](https://github.com/mcrute/tiny-ec2-bootstrap) are required before we can truly make `ami_user` configurable. - -* Currently, it is not possible to add/modify/remove arbitrary files (such as - service config files) on the filesystem which ultimately becomes the AMI. - One workaround is to use a "user data" script to make any necessary changes - (during the "default" runlevel) when an instance first launches. diff --git a/scripts/make-amis b/scripts/make-amis index d93a266..9ea3a16 100755 --- a/scripts/make-amis +++ b/scripts/make-amis @@ -18,7 +18,7 @@ PROFILE=$1; shift for BUILD in $BUILDS do - printf "\n*** $BUILD ***\n\n" + printf "\n*** %s ***\n\n" "$BUILD" BUILD_DIR="profile/$PROFILE/$BUILD" @@ -36,7 +36,7 @@ do ) # update core version profile's release if necessary if [ "$alpine_release" != "$release" ]; then - printf "=== New release ($alpine_release) detected! ===\n\n" + printf "=== New release (%s) detected! ===\n\n" "$alpine_release" sed -i '' -e "s/$release/$alpine_release/" "../profiles/version/$version" ./resolve-profile.py "$PROFILE" # NOTE: this does NOT update 'revision', it's at target profile/build level @@ -50,12 +50,10 @@ do ) | tee "$BUILD_DIR/output" EXIT=$(cat "$BUILD_DIR/exit") - if [ "$EXIT" = "0" ]; then + if [ "$EXIT" -eq 0 ]; then ./update-release.py "$PROFILE" "$BUILD" else # unless AMI revision already exists, exit grep -q 'is used by an existing AMI' "$BUILD_DIR/output" || exit "$EXIT" fi done - -# TODO? if PROFILE = alpine-amis then prune?, gen-releases? -- cgit v1.2.3