Skip to content
Snippets Groups Projects
Verified Commit 583fccca authored by Chris Coley's avatar Chris Coley
Browse files

Add SSH key mounting to the image

parent 2be34412
No related branches found
No related tags found
No related merge requests found
......@@ -4,13 +4,30 @@ FROM alpine:${ALPINE_VERSION}
ARG ANSIBLE_VERSION=2
RUN apk add --update --no-cache \
# Install latest version of these dependencies \
bash openssh sshpass rsync \
# Install a specific version of ansible-core with the latest compatible ansible \
bash openssh python3 sshpass rsync \
# Install specific version of ansible-core and latest compatible ansible \
ansible ansible-core~=${ANSIBLE_VERSION}
# Add entrypoint script
COPY <<EOF /entrypoint.sh
#!/bin/sh
set -e
cp -R /tmp/.ssh /root/.ssh
chown -R root:root /root/.ssh
exec "\$@"
EOF
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Make sure the temporary SSH directory exists since we reference it in the
# entrypoint script
RUN mkdir /tmp/.ssh
WORKDIR /ansible
ENTRYPOINT []
CMD ["ansible", "--help"]
# vi: set ts=4 sw=4 et ft=dockerfile:
......@@ -11,10 +11,16 @@ Images are tagged with the version of `ansible-core` included in the image. Ther
## Usage
The working directory is `/ansible`, so mount your ansible playbooks and inventory files into that direcotry.
The working directory is `/ansible`, so mount your ansible playbooks and inventory files into that directory.
```bash
docker run --rm -it -v $(pwd):/ansible ccoley/ansible:latest ansible -m ping
docker run --rm -it -v $(pwd):/ansible ccoley/ansible:latest ansible -m ping all
```
If you want to use your local SSH keys, known_hosts, and config in the container then mount them to `/tmp/.ssh` in the container.
```bash
docker run --rm -it -v $(pwd):/ansible -v ~/.ssh:/tmp/.ssh:ro ccoley/ansible:latest ansible -m ping all
```
## Building Images Locally
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment