ansible/Dockerfile

25 lines
958 B
Text
Raw Permalink Normal View History

2026-10-11 22:29:14 +02:00
# Ansible controller for the homelab, isolated from whatever Ansible is on the
# laptop. Build and run it with ansible-docker.sh (source it first).
FROM python:3.13-slim-trixie
# The container user gets the laptop user's uid/gid, so the forwarded SSH agent
# socket is usable and files written in the repo (kube/config) belong to you.
ARG UID=1000
ARG GID=1000
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssh-client git nano less ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g "$GID" ansible && useradd -m -u "$UID" -g "$GID" -s /bin/bash ansible
COPY requirements.txt requirements.yml /tmp/
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& ansible-galaxy collection install -r /tmp/requirements.yml -p /usr/share/ansible/collections
USER ansible
RUN mkdir -m 700 /home/ansible/.ssh
# nano -R: ansible-vault edit without backup or swap files
ENV EDITOR="nano -R"
WORKDIR /home/ansible/ansible