summaryrefslogtreecommitdiffstats
path: root/molecule/ubuntu
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-09-04 00:25:57 +0200
committerAhmed Abdelhalim <[email protected]>2025-09-04 00:25:57 +0200
commit6725e4cc8f4e91b4215813171fa06d365721abed (patch)
tree325a3a3629e11e95a4379e0dab9d6a91b08290ca /molecule/ubuntu
parent9314a3458a5b3add41cf31c41e8597165943840d (diff)
Refactor molecule testing to run a scenario per distro
Diffstat (limited to 'molecule/ubuntu')
-rw-r--r--molecule/ubuntu/Dockerfile.j230
-rw-r--r--molecule/ubuntu/converge.yml33
-rw-r--r--molecule/ubuntu/molecule.yml40
3 files changed, 103 insertions, 0 deletions
diff --git a/molecule/ubuntu/Dockerfile.j2 b/molecule/ubuntu/Dockerfile.j2
new file mode 100644
index 00000000..37199b55
--- /dev/null
+++ b/molecule/ubuntu/Dockerfile.j2
@@ -0,0 +1,30 @@
+# 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 iproute2 ifupdown \
+ && rm -Rf /var/lib/apt/lists/* \
+ && rm -Rf /usr/share/doc \
+ && rm -Rf /usr/share/man \
+ && apt-get clean
+
+# 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/ubuntu/converge.yml b/molecule/ubuntu/converge.yml
new file mode 100644
index 00000000..e80d8441
--- /dev/null
+++ b/molecule/ubuntu/converge.yml
@@ -0,0 +1,33 @@
+---
+- name: Converge
+ hosts: ubuntu
+ gather_facts: true
+ vars:
+ ansible_become_method: su
+ user_public_keys:
+ - "ssh-ed25519 AAAA...fMo"
+ - "ssh-rsa AAAA...4I3"
+ user_groups: ["wheel", "test_group"]
+ locales:
+ - "en_US.UTF-8 UTF-8"
+ timezone: "GMT"
+
+ python_global_version: "3.13"
+ python_versions:
+ - "3.13"
+ roles:
+ - role: "hostname"
+ - role: "network"
+ - role: "user"
+ - role: "ssh"
+ - role: "password_policy"
+ - role: "locales"
+ - role: "timezone"
+ - role: "wireguard"
+ - role: "wireguard_gateway"
+ - role: "homebrew"
+ - role: "python"
+ - role: "go"
+ - role: "docker"
+ - role: "podman"
+ - role: "ansible"
diff --git a/molecule/ubuntu/molecule.yml b/molecule/ubuntu/molecule.yml
new file mode 100644
index 00000000..a034f7fb
--- /dev/null
+++ b/molecule/ubuntu/molecule.yml
@@ -0,0 +1,40 @@
+---
+role_name_check: 1
+dependency:
+ name: galaxy
+ options:
+ ignore-errors: true
+driver:
+ name: podman
+platforms:
+ - name: ubuntu
+ dockerfile: Dockerfile.j2
+ 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:
+ 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