diff options
author | Jake Buchholz <tomalok@gmail.com> | 2019-05-30 21:04:11 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2019-07-05 12:51:09 -0700 |
commit | d28214fc5054199efa2046ed95c5e4e891c6b521 (patch) | |
tree | 68de3030c8c67194097e94ba0d41667abdfac4da | |
parent | 396bb8ab867d46217c943c0387979e862b9a05d5 (diff) | |
download | alpine-ec2-ami-d28214fc5054199efa2046ed95c5e4e891c6b521.tar.bz2 alpine-ec2-ami-d28214fc5054199efa2046ed95c5e4e891c6b521.tar.xz alpine-ec2-ami-d28214fc5054199efa2046ed95c5e4e891c6b521.zip |
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
-rw-r--r-- | .gitignore | 11 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | profiles/README.md | 7 | ||||
-rwxr-xr-x | scripts/make-amis | 8 |
4 files changed, 12 insertions, 23 deletions
@@ -2,14 +2,3 @@ | |||
2 | **/*.bak | 2 | **/*.bak |
3 | **/*.swp | 3 | **/*.swp |
4 | /build/ | 4 | /build/ |
5 | /profiles/* | ||
6 | !/profiles/README.md | ||
7 | !/profiles/base/ | ||
8 | !/profiles/arch/ | ||
9 | !/profiles/version/ | ||
10 | !/profiles/alpine.conf | ||
11 | !/profiles/example.conf | ||
12 | !/profiles/test.conf | ||
13 | /releases/* | ||
14 | !/releases/README.md | ||
15 | !/releases/alpine.yaml | ||
@@ -12,18 +12,24 @@ LEVEL := | |||
12 | PACKER := packer | 12 | PACKER := packer |
13 | export PACKER | 13 | export PACKER |
14 | 14 | ||
15 | require_var = $(if $(value $1),,$(error $1=... required)) | ||
16 | |||
15 | .PHONY: amis prune release-readme clean | 17 | .PHONY: amis prune release-readme clean |
16 | 18 | ||
17 | amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py | 19 | amis: build build/packer.json build/profile/$(PROFILE) build/update-release.py |
20 | @:$(call require_var, PROFILE) | ||
18 | build/make-amis $(PROFILE) $(BUILDS) | 21 | build/make-amis $(PROFILE) $(BUILDS) |
19 | 22 | ||
20 | prune: build build/prune-amis.py | 23 | prune: build build/prune-amis.py |
24 | @:$(call require_var, LEVEL) | ||
25 | @:$(call require_var, PROFILE) | ||
21 | build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD) | 26 | build/prune-amis.py $(LEVEL) $(PROFILE) $(BUILD) |
22 | 27 | ||
23 | release-readme: build build/gen-release-readme.py | 28 | release-readme: build build/gen-release-readme.py |
29 | @:$(call require_var, PROFILE) | ||
24 | build/gen-release-readme.py $(PROFILE) | 30 | build/gen-release-readme.py $(PROFILE) |
25 | 31 | ||
26 | build: $(SCRIPTS) | 32 | build: $(ALL_SCRIPTS) |
27 | [ -d build/profile ] || mkdir -p build/profile | 33 | [ -d build/profile ] || mkdir -p build/profile |
28 | python3 -m venv build/.py3 | 34 | python3 -m venv build/.py3 |
29 | build/.py3/bin/pip install pyhocon pyyaml boto3 | 35 | build/.py3/bin/pip install pyhocon pyyaml boto3 |
@@ -33,6 +39,7 @@ build/packer.json: build packer.conf | |||
33 | build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json | 39 | build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json |
34 | 40 | ||
35 | build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) | 41 | build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) |
42 | @:$(call require_var, PROFILE) | ||
36 | build/resolve-profile.py $(PROFILE) | 43 | build/resolve-profile.py $(PROFILE) |
37 | 44 | ||
38 | %.py: %.py.in build | 45 | %.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 @@ | |||
1 | # Profiles | 1 | # Profiles |
2 | 2 | ||
3 | Profiles are collections of related build definitions, which are used to | 3 | Profiles are collections of related build definitions, which are used to |
4 | generate the `variables.yaml` files that [Packer](https://packer.io) consumes | 4 | generate the `vars.json` files that [Packer](https://packer.io) consumes |
5 | when building AMIs. | 5 | when building AMIs. |
6 | 6 | ||
7 | Profiles use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md) | 7 | Profiles use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md) |
@@ -150,8 +150,3 @@ ami_access { | |||
150 | * The AMI's login user is currently hard coded to be `alpine`. Changes to | 150 | * The AMI's login user is currently hard coded to be `alpine`. Changes to |
151 | [tiny-ec2-bootstrap](https://github.com/mcrute/tiny-ec2-bootstrap) are | 151 | [tiny-ec2-bootstrap](https://github.com/mcrute/tiny-ec2-bootstrap) are |
152 | required before we can truly make `ami_user` configurable. | 152 | required before we can truly make `ami_user` configurable. |
153 | |||
154 | * Currently, it is not possible to add/modify/remove arbitrary files (such as | ||
155 | service config files) on the filesystem which ultimately becomes the AMI. | ||
156 | One workaround is to use a "user data" script to make any necessary changes | ||
157 | (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 | |||
18 | 18 | ||
19 | for BUILD in $BUILDS | 19 | for BUILD in $BUILDS |
20 | do | 20 | do |
21 | printf "\n*** $BUILD ***\n\n" | 21 | printf "\n*** %s ***\n\n" "$BUILD" |
22 | 22 | ||
23 | BUILD_DIR="profile/$PROFILE/$BUILD" | 23 | BUILD_DIR="profile/$PROFILE/$BUILD" |
24 | 24 | ||
@@ -36,7 +36,7 @@ do | |||
36 | ) | 36 | ) |
37 | # update core version profile's release if necessary | 37 | # update core version profile's release if necessary |
38 | if [ "$alpine_release" != "$release" ]; then | 38 | if [ "$alpine_release" != "$release" ]; then |
39 | printf "=== New release ($alpine_release) detected! ===\n\n" | 39 | printf "=== New release (%s) detected! ===\n\n" "$alpine_release" |
40 | sed -i '' -e "s/$release/$alpine_release/" "../profiles/version/$version" | 40 | sed -i '' -e "s/$release/$alpine_release/" "../profiles/version/$version" |
41 | ./resolve-profile.py "$PROFILE" | 41 | ./resolve-profile.py "$PROFILE" |
42 | # NOTE: this does NOT update 'revision', it's at target profile/build level | 42 | # NOTE: this does NOT update 'revision', it's at target profile/build level |
@@ -50,12 +50,10 @@ do | |||
50 | ) | tee "$BUILD_DIR/output" | 50 | ) | tee "$BUILD_DIR/output" |
51 | EXIT=$(cat "$BUILD_DIR/exit") | 51 | EXIT=$(cat "$BUILD_DIR/exit") |
52 | 52 | ||
53 | if [ "$EXIT" = "0" ]; then | 53 | if [ "$EXIT" -eq 0 ]; then |
54 | ./update-release.py "$PROFILE" "$BUILD" | 54 | ./update-release.py "$PROFILE" "$BUILD" |
55 | else | 55 | else |
56 | # unless AMI revision already exists, exit | 56 | # unless AMI revision already exists, exit |
57 | grep -q 'is used by an existing AMI' "$BUILD_DIR/output" || exit "$EXIT" | 57 | grep -q 'is used by an existing AMI' "$BUILD_DIR/output" || exit "$EXIT" |
58 | fi | 58 | fi |
59 | done | 59 | done |
60 | |||
61 | # TODO? if PROFILE = alpine-amis then prune?, gen-releases? | ||