Docker, Podman or real VMs as the Molecule driver: how do you choose?
AdvancedProductionTesting, CI/CD and Quality
Answer
- Docker / Podman (via
molecule-plugins[docker]or[podman]): seconds to start, cheap, perfect for package, file, template and user logic. Weak for kernel modules, sysctl, firewalld, SELinux, mounts and anything that needs a real init system. - VMs (EC2, Vagrant, or the
defaultdelegated driver with your own create/destroy playbooks): slow and costs money, but tests the real thing.
In production we use containers for every PR and a VM scenario (molecule test -s ec2) for roles that touch the kernel, networking or boot, run on merge or nightly. Podman is the natural choice on RHEL-based CI runners where rootless containers are the norm. Whatever the driver, the instance image must match production's OS major version.
More on Testing, CI/CD and Quality
What does a testing pyramid look like for Ansible code?BeginnerHow do you roll out `ansible-lint` profiles across a team without blocking everyone?IntermediateWhen do you use `skip_list`, `warn_list` and `# noqa`?IntermediateHow do you set up pre-commit hooks for an Ansible repo?BeginnerHow is a Molecule scenario laid out, and what does `molecule test` actually run?IntermediateHow do you test roles that manage systemd services inside Molecule containers?Advanced