Adding docker to ansible-server

This commit is contained in:
Kris Crawford 2025-06-02 08:00:04 -04:00
parent 91e257bc52
commit 2630b6a88d
3 changed files with 26 additions and 6 deletions

View File

@ -3,14 +3,14 @@
## Build steps
```shell
docker build -t ansible-docker -f ansible-server/Dockerfile .
docker build -t ansible-client -f ansible-client/Dockerfile .
docker build -t ansible-server:0.0.2 -f ansible-server/Dockerfile .
docker build -t ansible-client:0.0.1 -f ansible-client/Dockerfile .
```
## Starting containers
```shell
docker container run -it -v $(pwd):/tmp/ansible ansible-docker bash
docker container run -it -v $(pwd):/tmp/ansible -v /var/run/docker.sock:/var/run/docker.sock ansible-server:0.0.2 bash
for _i in {1..3}; do docker container run --name ansible-client$_i -it -d ansible-client; done
```

View File

@ -4,6 +4,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
software-properties-common \
openssh-client \
sshpass \
@ -13,8 +14,20 @@ RUN apt-get update \
curl \
rsync \
sudo \
less \
&& apt-get clean \
less
# Install docker
RUN curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
RUN chmod a+r /etc/apt/keyrings/docker.asc
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update -y
RUN apt-get install -y docker-ce docker-ce-cli
VOLUME /var/run/docker.sock
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man
@ -26,6 +39,7 @@ RUN groupadd --gid $USER_GID $USERNAME
RUN useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL >/etc/sudoers.d/$USERNAME
RUN chmod 0440 /etc/sudoers.d/$USERNAME
RUN sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/' /home/ansible/.bashrc
RUN pip3 install --no-cache-dir \
ansible \
@ -43,7 +57,6 @@ ENV ANSIBLE_FORCE_COLOR=true
ENV GOSS_FMT=documentation
ENV GOSS_COLOR=true
# Install goss for testing
RUN curl -L https://github.com/goss-org/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss
RUN chmod +rx /usr/local/bin/goss

View File

@ -16,6 +16,10 @@ command:
exit-status: 0
exec: "ansible --version"
timeout: 30000
ansible-builder:
exit-status: 0
exec: "ansible-builder --version"
timeout: 30000
ansible-lint:
exit-status: 0
exec: "ansible-lint --version"
@ -26,6 +30,9 @@ command:
curl:
exit-status: 0
exec: "curl --version"
docker:
exit-status: 0
exec: "docker --version"
git:
exit-status: 0
exec: "git version"