Ansible and Molecule with Fedora 41

When using Ansible and Molecule with Fedora 41, a few things must be adjusted so that Molecule can access the Docker image for Fedora 41.

This is probably due to some changes in the Python package and the new Dnf 5 package; if you use a default Docker Fedora 41 image, you get errors of the shape during the Molecule run:

To solve the problem, you must ensure that the packages “python3” and “python3-libdnf5” are installed in the Docker container used by Molecule during testing.

You can achieve that either by providing a custom Dockerfile for Molecule:

and this is an example of a Dockerfile:

Alternatively, you can specify the pre-built Docker Fedora 41 in the Molecule file:

And provide a “prepare.yml” file to install the above-mentioned required packages:

Note that we must use the built-in “raw” module and avoid gathering facts. Otherwise, we would get back to the original error message.

I hope you find this post helpful.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.