From 0a45093f25d929b8f16454a709b2ff677d6cb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Fri, 27 Feb 2026 12:12:49 +0100 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ README.md | 6 ++++++ almalinux/Dockerfile | 29 +++++++++++++++++++++++++++++ debian/Dockerfile | 26 ++++++++++++++++++++++++++ ubuntu/Dockerfile | 28 ++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 almalinux/Dockerfile create mode 100644 debian/Dockerfile create mode 100644 ubuntu/Dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e7f8d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +id_ansible_lab* +*.sw* diff --git a/README.md b/README.md new file mode 100644 index 0000000..6237ba8 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Immagini Docker per lab Ansible + +Il repository include i Dockerfile per tre immagini Docker basate su Debian 13, Almalinux 9 e Ubuntu 24.04 per riprodurre tramite container i sistemi operativi (attualmente) installati sulle VM in produzione al CED di Montelibretti (Area RM 1). + +Per il corretto funzionamento delle immagini, รจ necessario che esista una chiave pubblica `id_ansible.pub` nelle rispettive cartelle con i Dockerfile. Questa deve ovviamente corrispondere a una chiave SSH privata `id_ansible_lab` che `inventory.yaml` cerca in `~/.ssh/`. + diff --git a/almalinux/Dockerfile b/almalinux/Dockerfile new file mode 100644 index 0000000..896c77d --- /dev/null +++ b/almalinux/Dockerfile @@ -0,0 +1,29 @@ +FROM almalinux:9 + +RUN dnf update -y && \ + dnf install -y \ + openssh-server \ + sudo \ + python3 + #rm -rf /var/lib/apt/lists/* + +RUN mkdir /var/run/sshd + +RUN ssh-keygen -A + +RUN useradd -m -s /bin/bash nicolo && \ + echo "nicolo ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nicolo + +RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \ + sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config + +RUN mkdir /home/nicolo/.ssh && \ + chmod 700 /home/nicolo/.ssh + +COPY id_ansible_lab.pub /home/nicolo/.ssh/authorized_keys + +RUN chown nicolo:nicolo -R /home/nicolo/.ssh && chmod 600 /home/nicolo/.ssh/authorized_keys + +EXPOSE 22 +CMD ["/usr/sbin/sshd", "-D"] + diff --git a/debian/Dockerfile b/debian/Dockerfile new file mode 100644 index 0000000..ed3bf69 --- /dev/null +++ b/debian/Dockerfile @@ -0,0 +1,26 @@ +FROM debian:13 + +RUN apt-get update && \ + apt-get install -y \ + openssh-server \ + sudo \ + python3 \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +RUN useradd -m -s /bin/bash nicolo && \ + echo "nicolo ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nicolo + +RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \ + sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config + +RUN mkdir /home/nicolo/.ssh && \ + chmod 700 /home/nicolo/.ssh + +COPY id_ansible_lab.pub /home/nicolo/.ssh/authorized_keys + +RUN chown nicolo:nicolo -R /home/nicolo/.ssh && chmod 600 /home/nicolo/.ssh/authorized_keys + +EXPOSE 22 +CMD ["/usr/sbin/sshd", "-D"] + diff --git a/ubuntu/Dockerfile b/ubuntu/Dockerfile new file mode 100644 index 0000000..2aeaf37 --- /dev/null +++ b/ubuntu/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:24.04 + +RUN apt-get update && \ + apt-get install -y \ + openssh-server \ + sudo \ + python3 \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir /var/run/sshd + +RUN useradd -m -s /bin/bash nicolo && \ + echo "nicolo ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nicolo + +RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \ + sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config + +RUN mkdir /home/nicolo/.ssh && \ + chmod 700 /home/nicolo/.ssh + +COPY id_ansible_lab.pub /home/nicolo/.ssh/authorized_keys + +RUN chown nicolo:nicolo -R /home/nicolo/.ssh && chmod 600 /home/nicolo/.ssh/authorized_keys + +EXPOSE 22 +CMD ["/usr/sbin/sshd", "-D"] +