mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
add helper for building ami
This commit is contained in:
35
e2e/terraform/packer/build
Executable file
35
e2e/terraform/packer/build
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: build <target>
|
||||
|
||||
Build an AMI for the target configuration
|
||||
|
||||
Examples
|
||||
build ubuntu-bionic-amd64
|
||||
|
||||
EOF
|
||||
|
||||
exit 2
|
||||
}
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
target=${1/%.pkr.hcl/}
|
||||
|
||||
directory=$(dirname "$0")
|
||||
cd ${directory}
|
||||
|
||||
if ! test -f "${target}.pkr.hcl"; then
|
||||
echo "${target}.pkr.hcl is not present" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sha=$(git log -n 1 --pretty=format:%H ${dirname})
|
||||
echo packer build --var "build_sha=${sha}" ${target}.pkr.hcl
|
||||
packer build --var "build_sha=${sha}" ${target}.pkr.hcl
|
||||
Reference in New Issue
Block a user