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:
parent
396bb8ab86
commit
d28214fc50
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -2,14 +2,3 @@
|
||||||
**/*.bak
|
**/*.bak
|
||||||
**/*.swp
|
**/*.swp
|
||||||
/build/
|
/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
|
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -12,18 +12,24 @@ LEVEL :=
|
||||||
PACKER := packer
|
PACKER := packer
|
||||||
export PACKER
|
export PACKER
|
||||||
|
|
||||||
|
require_var = $(if $(value $1),,$(error $1=... required))
|
||||||
|
|
||||||
.PHONY: amis prune release-readme clean
|
.PHONY: amis prune release-readme clean
|
||||||
|
|
||||||
amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py
|
amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py
|
||||||
|
@:$(call require_var, PROFILE)
|
||||||
build/make-amis $(PROFILE) $(BUILDS)
|
build/make-amis $(PROFILE) $(BUILDS)
|
||||||
|
|
||||||
prune: build build/prune-amis.py
|
prune: build build/prune-amis.py
|
||||||
|
@:$(call require_var, LEVEL)
|
||||||
|
@:$(call require_var, PROFILE)
|
||||||
build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD)
|
build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD)
|
||||||
|
|
||||||
release-readme: build build/gen-release-readme.py
|
release-readme: build build/gen-release-readme.py
|
||||||
|
@:$(call require_var, PROFILE)
|
||||||
build/gen-release-readme.py $(PROFILE)
|
build/gen-release-readme.py $(PROFILE)
|
||||||
|
|
||||||
build: $(SCRIPTS)
|
build: $(ALL_SCRIPTS)
|
||||||
[ -d build/profile ] || mkdir -p build/profile
|
[ -d build/profile ] || mkdir -p build/profile
|
||||||
python3 -m venv build/.py3
|
python3 -m venv build/.py3
|
||||||
build/.py3/bin/pip install pyhocon pyyaml boto3
|
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/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json
|
||||||
|
|
||||||
build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES)
|
build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES)
|
||||||
|
@:$(call require_var, PROFILE)
|
||||||
build/resolve-profile.py $(PROFILE)
|
build/resolve-profile.py $(PROFILE)
|
||||||
|
|
||||||
%.py: %.py.in build
|
%.py: %.py.in build
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Profiles
|
# Profiles
|
||||||
|
|
||||||
Profiles are collections of related build definitions, which are used to
|
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.
|
when building AMIs.
|
||||||
|
|
||||||
Profiles use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md)
|
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
|
* 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
|
[tiny-ec2-bootstrap](https://github.com/mcrute/tiny-ec2-bootstrap) are
|
||||||
required before we can truly make `ami_user` configurable.
|
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.
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ PROFILE=$1; shift
|
||||||
|
|
||||||
for BUILD in $BUILDS
|
for BUILD in $BUILDS
|
||||||
do
|
do
|
||||||
printf "\n*** $BUILD ***\n\n"
|
printf "\n*** %s ***\n\n" "$BUILD"
|
||||||
|
|
||||||
BUILD_DIR="profile/$PROFILE/$BUILD"
|
BUILD_DIR="profile/$PROFILE/$BUILD"
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ do
|
||||||
)
|
)
|
||||||
# update core version profile's release if necessary
|
# update core version profile's release if necessary
|
||||||
if [ "$alpine_release" != "$release" ]; then
|
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"
|
sed -i '' -e "s/$release/$alpine_release/" "../profiles/version/$version"
|
||||||
./resolve-profile.py "$PROFILE"
|
./resolve-profile.py "$PROFILE"
|
||||||
# NOTE: this does NOT update 'revision', it's at target profile/build level
|
# NOTE: this does NOT update 'revision', it's at target profile/build level
|
||||||
|
@ -50,12 +50,10 @@ do
|
||||||
) | tee "$BUILD_DIR/output"
|
) | tee "$BUILD_DIR/output"
|
||||||
EXIT=$(cat "$BUILD_DIR/exit")
|
EXIT=$(cat "$BUILD_DIR/exit")
|
||||||
|
|
||||||
if [ "$EXIT" = "0" ]; then
|
if [ "$EXIT" -eq 0 ]; then
|
||||||
./update-release.py "$PROFILE" "$BUILD"
|
./update-release.py "$PROFILE" "$BUILD"
|
||||||
else
|
else
|
||||||
# unless AMI revision already exists, exit
|
# unless AMI revision already exists, exit
|
||||||
grep -q 'is used by an existing AMI' "$BUILD_DIR/output" || exit "$EXIT"
|
grep -q 'is used by an existing AMI' "$BUILD_DIR/output" || exit "$EXIT"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO? if PROFILE = alpine-amis then prune?, gen-releases?
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user