Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Docker
Ansible
Commits
583fccca
Verified
Commit
583fccca
authored
3 months ago
by
Chris Coley
Browse files
Options
Downloads
Patches
Plain Diff
Add SSH key mounting to the image
parent
2be34412
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+20
-3
20 additions, 3 deletions
Dockerfile
README.md
+8
-2
8 additions, 2 deletions
README.md
with
28 additions
and
5 deletions
Dockerfile
+
20
−
3
View file @
583fccca
...
...
@@ -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:
This diff is collapsed.
Click to expand it.
README.md
+
8
−
2
View file @
583fccca
...
...
@@ -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 direc
o
try.
The working directory is
`/ansible`
, so mount your ansible playbooks and inventory files into that direct
o
ry.
```
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment