11{
22 pkgs ,
33 lib ,
4+ docker-image-ubuntu ,
45} :
56let
6- ubuntu-cloudimg =
7- let
8- cloudImg = builtins . fetchurl {
9- url = "http://cloud-images-archive.ubuntu.com/releases/noble/release-20250430/ubuntu-24.04-server-cloudimg-amd64-root.tar.xz" ;
10- sha256 = "sha256:0rfi3qqs0sqarixfic7pzjpx7d4vldv2d98c5zjv7b90mirznvf9" ;
11- } ;
12- in
13- pkgs . runCommand "ubuntu-cloudimg" { nativeBuildInputs = [ pkgs . xz ] ; } ''
14- mkdir -p $out
15- tar --exclude='dev/*' \
16- --exclude='etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service' \
17- --exclude='etc/systemd/system/multi-user.target.wants/systemd-resolved.service' \
18- --exclude='usr/lib/systemd/system/tpm-udev.service' \
19- --exclude='usr/lib/systemd/system/systemd-remount-fs.service' \
20- --exclude='usr/lib/systemd/system/systemd-resolved.service' \
21- --exclude='var/lib/apt/lists/*' \
22- -xJf ${ cloudImg } -C $out
23- rm $out/bin $out/lib $out/lib64 $out/sbin
24- mkdir -p $out/run/systemd && echo 'docker' > $out/run/systemd/container
25- mkdir $out/var/lib/apt/lists/partial
26- '' ;
27-
28- dockerImageUbuntu = pkgs . dockerTools . buildImage {
29- name = "ubuntu-cloudimg" ;
30- tag = "0.1" ;
31- created = "now" ;
32- extraCommands = ''
33- ln -s usr/bin
34- ln -s usr/lib
35- ln -s usr/lib64
36- ln -s usr/sbin
37- '' ;
38- copyToRoot = pkgs . buildEnv {
39- name = "image-root" ;
40- pathsToLink = [ "/" ] ;
41- paths = [ ubuntu-cloudimg ] ;
42- } ;
43- config . Cmd = [ "/lib/systemd/systemd" ] ;
44- } ;
45-
467 dockerImageUbuntuWithTools =
478 let
489 tools = [ pkgs . ansible ] ;
5213 tag = "0.1" ;
5314 created = "now" ;
5415 maxLayers = 30 ;
55- fromImage = dockerImageUbuntu ;
16+ fromImage = docker-image-ubuntu ;
17+ compressor = "zstd" ;
5618 config = {
5719 Env = [
5820 "PATH=${ lib . makeBinPath tools } :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@@ -69,19 +31,18 @@ pkgs.writeShellApplication {
6931 requests
7032 pytest
7133 pytest-testinfra
34+ pytest-xdist
7235 rich
7336 ]
7437 ) )
7538 ] ;
7639 text = ''
7740 echo "Running Ansible tests..."
7841 export DOCKER_IMAGE=${ dockerImageUbuntuWithTools . imageName } :${ dockerImageUbuntuWithTools . imageTag }
79- if ! docker image inspect $DOCKER_IMAGE > /dev/null; then
80- echo "Loading Docker image..."
81- docker load < ${ dockerImageUbuntuWithTools }
82- fi
83- ANSIBLE_DIR=${ ../../ansible }
84- pytest -p no:cacheprovider -s -v "$@" $ANSIBLE_DIR/tests --ansible-dir=$ANSIBLE_DIR --docker-image=$DOCKER_IMAGE
42+ echo "Loading Docker image..."
43+ docker load < ${ dockerImageUbuntuWithTools }
44+ FLAKE_DIR=${ ../.. }
45+ pytest -x -p no:cacheprovider -s -v "$@" $FLAKE_DIR/ansible/tests --flake-dir=$FLAKE_DIR --docker-image=$DOCKER_IMAGE
8546 '' ;
8647 meta = with pkgs . lib ; {
8748 description = "Ansible test runner" ;
0 commit comments