Skip to content

Commit

Permalink
revert: addition of docker.sock mount
Browse files Browse the repository at this point in the history
  • Loading branch information
wastrachan committed Feb 20, 2024
1 parent 7093b6e commit a5afa79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ RUN set -eux; \
# Create ansible user with explicit uid
RUN <<EOF
set -eux
groupadd -r docker --gid=999
groupadd -r ansible --gid=1000
useradd -m -u 1000 -g 1000 -G 999 ansible
useradd -m -u 1000 -g 1000 ansible
mkdir -p /home/ansible/.ssh
chown -R ansible:ansible /home/ansible
EOF
Expand All @@ -47,7 +46,6 @@ EOF

VOLUME /app
VOLUME /home/ansible/.ssh
VOLUME /var/run/docker.sock
WORKDIR /app
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This project builds a docker image with all of the dependencies required to run
| -------------------- | ------- | -------------------------------------- |
| `PUID` | `1000` | User ID of the primary ansible user |
| `PGID` | `1000` | Group ID for the priamry ansible group |
| `DOCKERGID` | `999` | Group ID for the docker group |

### Users

Expand All @@ -20,11 +19,10 @@ This project builds a docker image with all of the dependencies required to run

### Mounts

| Mount | Description |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `/app` | The expected mount path for an ansible project |
| `/home/ansible/.ssh` | The default ansible user's SSH Directory. Private keys can be mounted inside of this directory for use by ansible-playbook during runs. |
| `/var/run/docker.sock` | This container supports access to the host's docker daemon for testing purposes. Optionally mount the docker socket if you require this. |
| Mount | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `/app` | The expected mount path for an ansible project |
| `/home/ansible/.ssh` | The default ansible user's SSH Directory. Private keys can be mounted inside of this directory for use by ansible-playbook during runs. |

## Usage

Expand All @@ -37,7 +35,6 @@ docker run \
--network host \
-e PUID=${id -u} \
-e PGID=${id -g} \
-e DOCKERGID=${getent group docker | cut -d ':' -f 3} \
--mount type=bind,source=".",target=/app \
--mount type=bind,source="${HOME}/.ssh",target=/home/ansible/.ssh,readonly \
ghcr.io/gamersoutreach/ansible-runner:latest \
Expand Down
4 changes: 0 additions & 4 deletions overlay/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ set -e

PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
DOCKERGID="${DOCKERGID:-999}"

# Set UID/GID of ansible user
sed -i "s/^ansible\:x\:1000\:1000/ansible\:x\:$PUID\:$PGID/" /etc/passwd
sed -i "s/^ansible\:x\:1000/ansible\:x\:$PGID/" /etc/group

# Set the GID of the docker group
sed -i "s/^docker\:x\:999/docker\:x\:$DOCKERGID/" /etc/group

# Set permissions on home folder, excluding .ssh mount
chown $PUID:$PGID /home/ansible
find /home/ansible -mindepth 1 -maxdepth 1 -not -name ".ssh" -exec chown -R $PUID:$PGID {} \;
Expand Down

0 comments on commit a5afa79

Please sign in to comment.