-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildspec.yml
34 lines (34 loc) · 1.19 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
version: 0.2
run-as: root
env:
variables:
PACKER_VERSION: "1.3.3"
USER: root
phases:
pre_build:
commands:
- apt-get update -y && apt-get install -y --no-install-recommends dnsutils
- echo "Installing Packer"
- curl -o packer.zip "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
- unzip -o packer.zip -d /usr/local/bin
- echo "Installing Ansible"
- pip install --upgrade pip setuptools awscli
- pip install git+https://github.com/ansible/[email protected]
- pip install ansible-lint
- packer -v
build:
commands:
- make ami | tee build.log
post_build:
commands:
- sed -i.bak "s/<<AMI-NAME>>/$(grep -Po '"Name"\:\ \K"[^"]*"' build.log | head -1 | tr -d '"')/" unops_build_event.json
- egrep "${AWS_REGION}\:\sami\-" build.log | cut -d' ' -f2 > ami_id.txt
- test -s ami_id.txt || exit 1
- sed -i.bak "s/<<AMI-ID>>/$(cat ami_id.txt)/g" unops_build_event.json
- aws events put-events --entries file://unops_build_event.json
- echo "build completed on `date`"
artifacts:
files:
- unops_build_event.json
- build.log
discard-paths: yes