-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using geerlingguy/docker-debian10-ansible + geerlingguy/docker-debian11-ansible in Ansible molecule currently do not work with systemd, see: geerlingguy/docker-debian11-ansible#4. Instead, took Dockfiles from @aussielunix (Thx!) found here (but removed 'Australia/Sydney' timezone): * https://gitlab.com/aussielunix/ansible/molecule-containers/-/blob/main/debian/buster/Dockerfile * https://gitlab.com/aussielunix/ansible/molecule-containers/-/blob/main/debian/bullseye/Dockerfile Compare with @geerlingguy's current Dockerfiles: * https://github.com/geerlingguy/docker-debian10-ansible/blob/6f6a1650421afc953eb11439db9e5dabcc4d3afe/Dockerfile * https://github.com/geerlingguy/docker-debian11-ansible/blob/101602c7b9e7b3e100b7435eaa455b94189b2d47/Dockerfile Note, that when using `dockerfile`, `image` seems to be needed too. Used `docker.io/debian:$DISTRIBUTION-slim` for `image` as they are the base images for @aussielunix's Dockerfiles. I could have used @aussielinux gitlab container registry as `image`, but currently 'debian:bullseye' is missing: * https://gitlab.com/aussielunix/ansible/molecule-containers/container_registry/3343441 See: geerlingguy/docker-debian11-ansible#4 (comment)
- Loading branch information
Showing
3 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM docker.io/debian:bullseye-slim | ||
|
||
LABEL org.opencontainers.image.description="Debian 11 Container for Molecule" | ||
LABEL org.opencontainers.image.source=https://gitlab.com/aussielunix/ansible/molecule-containers | ||
|
||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US.UTF-8 | ||
|
||
# Avoid apt warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Configure apt and install packages | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends systemd systemd-sysv \ | ||
sudo procps python3-pip python3-dev python3-setuptools python3-wheel \ | ||
# Clean up | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ | ||
&& apt-get clean | ||
|
||
# Create `ansible` user and group with sudo permissions | ||
RUN set -xe \ | ||
&& useradd -m -U -G sudo -s /bin/bash ansible \ | ||
&& sed -i "/^%sudo/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers | ||
|
||
# Upgrade pip to latest version to avoid wheel / cryptography issues | ||
RUN pip3 install --upgrade pip | ||
|
||
# Install Ansible via pip. | ||
RUN pip3 install ansible-core ansible-lint cryptography | ||
|
||
# Install Ansible inventory file. | ||
RUN mkdir -p /etc/ansible | ||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \ | ||
/etc/systemd/system/*.wants/* \ | ||
/lib/systemd/system/local-fs.target.wants/* \ | ||
/lib/systemd/system/sockets.target.wants/*udev* \ | ||
/lib/systemd/system/sockets.target.wants/*initctl* \ | ||
/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \ | ||
/lib/systemd/system/systemd-update-utmp* | ||
|
||
CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM docker.io/debian:buster-slim | ||
|
||
LABEL org.opencontainers.image.description="Debian 10 Container for Molecule" | ||
LABEL org.opencontainers.image.source=https://gitlab.com/aussielunix/ansible/molecule-containers | ||
|
||
ENV LC_ALL en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US.UTF-8 | ||
|
||
# Avoid apt warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Configure apt and install packages | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends systemd systemd-sysv \ | ||
sudo procps python3-pip python3-dev python3-setuptools python3-wheel \ | ||
# Clean up | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ | ||
&& apt-get clean | ||
|
||
# Create `ansible` user and group with sudo permissions | ||
RUN set -xe \ | ||
&& useradd -m -U -G sudo -s /bin/bash ansible \ | ||
&& sed -i "/^%sudo/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers | ||
|
||
# Upgrade pip to latest version to avoid wheel / cryptography issues | ||
RUN pip3 install --upgrade pip | ||
|
||
# Install Ansible via pip. | ||
RUN pip3 install ansible-core ansible-lint cryptography | ||
|
||
# Install Ansible inventory file. | ||
RUN mkdir -p /etc/ansible | ||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \ | ||
/etc/systemd/system/*.wants/* \ | ||
/lib/systemd/system/local-fs.target.wants/* \ | ||
/lib/systemd/system/sockets.target.wants/*udev* \ | ||
/lib/systemd/system/sockets.target.wants/*initctl* \ | ||
/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \ | ||
/lib/systemd/system/systemd-update-utmp* | ||
|
||
CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters