├── README.md └── Dockerfile /README.md: -------------------------------------------------------------------------------- 1 | ## Docker-packer-ansible 2 | 3 | This image aims to provide a usable packer image with ansible slipstreamed 4 | inside for easy utilization of Ansible Local/Remote builders! 5 | 6 | A few notes: 7 | 8 | * I've based off the most official Packer image, `hashicorp/packer` 9 | * This utilizes Alpine Linux which means its more nimble ;) 10 | * The entrypoint has been reset to the Docker default `/bin/sh/ -c` so this 11 | image is more standardized for things like `gitlab-runner` or other 12 | application. 13 | * I'll maintain tags which specify both packer+ansible versions, although I will 14 | only update this as I need to for myself and my uses. Pull Requests are very 15 | welcome and will be responded to as quickly as possible! 16 | 17 | 18 | #### Example 19 | 20 | Given you bind mount a directory `ami_build` which has your packer.json 21 | and related ansible scripts, something like this should work. 22 | 23 | ``` 24 | docker run -v /home/user/ami_build:/build -ti -e AWS_ACCESS_KEY=blah 25 | -e AWS_SECRET_KEY=blah inanimate/packer-ansible "packer build packer.json" 26 | ``` 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM outlandish/ansible:2.9.10.2 2 | 3 | # Define our acceptable ansible version 4 | ENV PACKER_VERSION=1.1.1 5 | ENV PACKER_SHA256SUM=822fe76c2dfe699f187ef8c44537d10453a1545db620e40b345cf6991a690f7d 6 | 7 | RUN apt-get update -y && apt-get install -y git bash wget openssl zip 8 | 9 | ADD https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip ./ 10 | ADD https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS ./ 11 | 12 | RUN sed -i '/.*linux_amd64.zip/!d' packer_${PACKER_VERSION}_SHA256SUMS 13 | RUN sha256sum -c --status packer_${PACKER_VERSION}_SHA256SUMS 14 | RUN unzip packer_${PACKER_VERSION}_linux_amd64.zip -d /bin 15 | RUN rm -f packer_${PACKER_VERSION}_linux_amd64.zip 16 | 17 | RUN groupadd -g 999 appuser && \ 18 | useradd -r -u 999 -g appuser appuser 19 | 20 | 21 | # Set a default working dir (nice for bind mounting things inside) 22 | RUN mkdir /build && \ 23 | chown -R appuser:appuser /build && \ 24 | mkdir /home/appuser && \ 25 | chown -R appuser:appuser /home/appuser 26 | 27 | USER appuser 28 | 29 | WORKDIR /build 30 | 31 | # Packer needs this set: 32 | # https://github.com/mitchellh/packer/blob/49067e732a66c9f7a87843a2c91100de112b21cc/provisioner/ansible/provisioner.go#L127 33 | ENV USER appuser 34 | 35 | # Set our entrypoint back to the default (gitlab-runner needs this) 36 | ENTRYPOINT [] 37 | --------------------------------------------------------------------------------