diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ab02fc..2ab7596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,33 @@ name: CI - master jobs: + build: + name: Build Rocky9 container image + # Upstream rockylinux:9.3 images don't contain systemd, which means /sbin/init fails. + # A workaround of using "/bin/bash -c 'dnf -y install systemd && /sbin/init'" + # as the container command is flaky. + # This job builds an image using the upstream rockylinux:9.3 image which ensures + # that the image used for the molecule workflow is always updated. + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: molecule/images + steps: + - name: Check out the codebase. + uses: actions/checkout@v4 + + - name: Build image + run: podman build -t rocky93systemd:latest . + + - name: Save image + run: podman save --output rocky93systemd.docker rocky93systemd:latest + + - name: Upload rocky9 image + uses: actions/upload-artifact@v4 + with: + name: rocky93systemd + path: molecule/images/rocky93systemd.docker + molecule: name: Molecule # Workaround: systemd/kernel compatibility issue: @@ -18,13 +45,14 @@ jobs: # See: # - https://bugzilla.redhat.com/show_bug.cgi?id=190144 # - https://github.com/systemd/systemd/pull/16424 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + needs: build strategy: fail-fast: false matrix: image: - 'rockylinux:8.9' - - 'rockylinux:9.3' + - 'localhost/rocky93systemd' scenario: - test1 - test1b @@ -42,13 +70,24 @@ jobs: - test12 - test13 - test14 - exclude: [] steps: - name: Check out the codebase. uses: actions/checkout@v4 + - name: Download rocky9 container image + uses: actions/download-artifact@v4 + with: + name: rocky93systemd + path: molecule/images/rocky93systemd.docker + if: matrix.image == 'localhost/rocky93systemd' + + - name: Load rocky9 container image + run: podman load --input rocky93systemd.docker/rocky93systemd.docker + working-directory: molecule/images + if: matrix.image == 'localhost/rocky93systemd' + - name: Set up Python 3. uses: actions/setup-python@v4 with: diff --git a/molecule/README.md b/molecule/README.md index 9fed9a6..16126cb 100644 --- a/molecule/README.md +++ b/molecule/README.md @@ -39,17 +39,18 @@ Local installation on a RockyLinux 8.x machine looks like: pip install -r molecule/requirements.txt ansible-galaxy collection install containers.podman:>=1.10.1 -Then to run tests, e.g.:: +Build a RockyLinux 9.3 image with systemd included: - cd ansible-role-openhpc/ - MOLECULE_IMAGE=rockylinux:8.9 molecule test --all - -During development you may want to: + cd ansible-role-openhpc/molecule/images + podman build -t rocky93systemd:latest . -- See some debugging information by prepending: +Run tests, e.g.: - MOLECULE_NO_LOG="false" ... + cd ansible-role-openhpc/ + MOLECULE_NO_LOG="false" MOLECULE_IMAGE=rockylinux:8.9 molecule test --all -- Prevent destroying insstances using: +where the image may be `rockylinux:8.9` or `localhost/rocky93systemd`. - molecule test --destroy never +Other useful options during development: +- Prevent destroying instances by using `molecule test --destroy never` +- Run only a single test using e.g. `molecule test --scenario test5` diff --git a/molecule/images/Dockerfile b/molecule/images/Dockerfile new file mode 100644 index 0000000..ba6f78b --- /dev/null +++ b/molecule/images/Dockerfile @@ -0,0 +1,2 @@ +FROM rockylinux:9.3 +RUN dnf install -y systemd && dnf clean all diff --git a/molecule/test4/molecule.yml b/molecule/test4/molecule.yml index 838d009..29d30ca 100644 --- a/molecule/test4/molecule.yml +++ b/molecule/test4/molecule.yml @@ -7,7 +7,7 @@ platforms: pre_build_image: true groups: - testohpc_login - command: "/bin/bash -c 'dnf -y install systemd && /sbin/init'" # not in RL9 image + command: /sbin/init tmpfs: - /run - /tmp @@ -19,7 +19,7 @@ platforms: pre_build_image: true groups: - testohpc_compute - command: "/bin/bash -c 'dnf -y install systemd && /sbin/init'" # not in RL9 image + command: /sbin/init tmpfs: - /run - /tmp @@ -31,7 +31,7 @@ platforms: pre_build_image: true groups: - testohpc_compute - command: "/bin/bash -c 'dnf -y install systemd && /sbin/init'" # not in RL9 image + command: /sbin/init tmpfs: - /run - /tmp