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
This commit is contained in:
Jake Buchholz 2019-05-30 21:04:11 -07:00 committed by Mike Crute
parent 396bb8ab86
commit d28214fc50
4 changed files with 12 additions and 23 deletions

11
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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?