diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-08-11 00:32:00 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-08-11 00:32:00 +0200 |
| commit | 20ab3adb6b08944235c707490449c8906394564f (patch) | |
| tree | 8f0bded9360fde2cb6779d4e8cd50d41a3741c4c /molecule/default | |
| parent | b837d1af24552836cf85a17013ca7b210e1b727c (diff) | |
Add network role
Diffstat (limited to 'molecule/default')
| -rw-r--r-- | molecule/default/Dockerfile.archlinux.j2 | 24 | ||||
| -rw-r--r-- | molecule/default/Dockerfile.raspberrypi.j2 | 24 | ||||
| -rw-r--r-- | molecule/default/Dockerfile.ubuntu.j2 | 29 | ||||
| -rw-r--r-- | molecule/default/converge.yml | 9 | ||||
| -rw-r--r-- | molecule/default/molecule.yml | 41 |
5 files changed, 127 insertions, 0 deletions
diff --git a/molecule/default/Dockerfile.archlinux.j2 b/molecule/default/Dockerfile.archlinux.j2 new file mode 100644 index 00000000..1d5a1cd5 --- /dev/null +++ b/molecule/default/Dockerfile.archlinux.j2 @@ -0,0 +1,24 @@ +FROM docker.io/library/archlinux + +ENV container docker + +RUN pacman -Syu --noconfirm --needed python3 \ + && pacman -Scc --noconfirm + +RUN (cd /lib/systemd/system/sysinit.target.wants/; \ + for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ + rm -f /lib/systemd/system/multi-user.target.wants/*;\ + rm -f /etc/systemd/system/*.wants/*;\ + rm -f /lib/systemd/system/local-fs.target.wants/*; \ + rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f /lib/systemd/system/basic.target.wants/*;\ + rm -f /lib/systemd/system/anaconda.target.wants/*; + +# Workaround archlinux not including any non-indo-european locales +# https://gitlab.archlinux.org/archlinux/archlinux-docker/-/issues/59 +RUN cp -r /usr/share/i18n/locales/en_US /usr/share/i18n/locales/de_DE; + +VOLUME ["/sys/fs/cgroup"] + +CMD ["/lib/systemd/systemd"] diff --git a/molecule/default/Dockerfile.raspberrypi.j2 b/molecule/default/Dockerfile.raspberrypi.j2 new file mode 100644 index 00000000..1b1133f4 --- /dev/null +++ b/molecule/default/Dockerfile.raspberrypi.j2 @@ -0,0 +1,24 @@ +# Based on the amazing work of geerlingguy <3 +# FROM docker.io/geerlingguy/docker-debian12-ansible +FROM docker.io/library/debian:bookworm + +ARG DEBIAN_FRONTEND=noninteractive + +ENV container docker + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + systemd python3 avahi-daemon \ + && rm -Rf /var/lib/apt/lists/* \ + && rm -Rf /usr/share/doc \ + && rm -Rf /usr/share/man \ + && apt-get clean + +RUN rm -f /lib/systemd/system/multi-user.target.wants/getty.target + +# Mimic Raspberry OS default boot (for testing) +RUN systemctl enable avahi-daemon + +VOLUME ["/sys/fs/cgroup", "/tmp", "/run", "/opt"] + +CMD ["/lib/systemd/systemd"] diff --git a/molecule/default/Dockerfile.ubuntu.j2 b/molecule/default/Dockerfile.ubuntu.j2 new file mode 100644 index 00000000..4cf904ed --- /dev/null +++ b/molecule/default/Dockerfile.ubuntu.j2 @@ -0,0 +1,29 @@ +# Based on the amazing work of geerlingguy <3 +# FROM docker.io/geerlingguy/docker-ubuntu2404-ansible +FROM docker.io/library/ubuntu:noble + +ARG DEBIAN_FRONTEND=noninteractive + +ENV container docker + +RUN apt-get update \ + && apt-get install -y --no-install-recommends locales systemd avahi-daemon python3 \ + && apt-get clean \ + && rm -Rf /var/lib/apt/lists/* \ + && rm -Rf /usr/share/doc \ + && rm -Rf /usr/share/man + +# Fix potential UTF-8 errors with ansible-test. +RUN locale-gen en_US.UTF-8 + +# Remove unnecessary getty and udev targets that result in high CPU usage when using +# multiple containers with Molecule (https://github.com/ansible/molecule/issues/1104) +RUN rm -f /lib/systemd/system/systemd*udev* \ + && rm -f /lib/systemd/system/getty.target + +# Mimic Ubuntu OS default boot (for testing) +RUN systemctl enable avahi-daemon + +VOLUME ["/sys/fs/cgroup", "/tmp", "/run", "/opt"] + +CMD ["/lib/systemd/systemd"] diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 00000000..d0c2418d --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,9 @@ +--- +- name: Converge + hosts: instance + vars: + ansible_become_method: su + network_wifi_ssid: "TEST_WIFI_SSID" + network_wifi_pass: "TEST_WIFI_PASS" + roles: + - role: network diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 00000000..c0ec4e96 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,41 @@ +--- +role_name_check: 1 +dependency: + name: galaxy + options: + ignore-errors: true +driver: + name: podman +platforms: + - name: instance + image: ${MOLECULE_DISTRO:-archlinux} + dockerfile: Dockerfile.${MOLECULE_DISTRO:-archlinux}.j2 + platform: "${MOLECULE_PLATFORM:-linux/amd64}" + pre_build_image: false + privileged: true + command: ${MOLECULE_COMMAND:-"/lib/systemd/systemd"} + tmpfs: + "/tmp": "rw" + "/run": "rw,exec" + volumes: + - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + cgroupns_mode: host +provisioner: + name: ansible + inventory: + links: + host_vars: "../../host_vars/" + group_vars: "../../group_vars/" + env: + MOLECULE_DISTRO: "${MOLECULE_DISTRO:-archlinux}" + ANSIBLE_ROLES_PATH: "../../roles" + config_options: + defaults: + callback_result_format: yaml + interpreter_python: /usr/bin/python3 + ssh_connection: + pipelining: true + playbooks: + converge: converge.yml +verifier: + name: ansible |
