Ansible Testing with Molecule Flashcards
6 cards from real Ansible Automation practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Ansible Testing with Molecule flashcards as text
What Python package must be installed to use Molecule with the Docker driver in modern versions?
Answer: molecule-plugins[docker] (the molecule-docker package from the molecule-plugins collection)
Since Molecule 4.0, drivers were moved to the 'molecule-plugins' package. The Docker driver requires 'molecule-plugins[docker]'.
How do you configure Molecule to test a role on a container that uses systemd as its init system?
Answer: Use a systemd-enabled container image (e.g., geerlingguy/docker-centos8-ansible) and set privileged: true with /sys/fs/cgroup volume mount
Systemd requires privileged containers with proper cgroup access, and pre-built systemd-ready images (like geerlingguy's Ansible test images) simplify this setup.
What does 'ansible-lint' do in the context of Molecule testing?
Answer: It statically analyzes Ansible playbooks and roles for best practice violations, style issues, and potential bugs before running tests
ansible-lint checks Ansible code quality against community best practices, catching issues like missing task names, deprecated module usage, and style violations.
How do you pass variables to the role under test in a Molecule converge.yml?
Answer: Define variables in the 'vars' section of the play in converge.yml, or use a separate molecule/default/group_vars/ directory
converge.yml is a regular Ansible playbook where you can set variables via 'vars', 'vars_files', or group_vars/host_vars to control role behavior during testing.
What is the 'verify' phase in Molecule and what are the two main verifier options?
Answer: The verify phase runs post-role assertions to confirm correct configuration; main verifiers are 'ansible' (using Ansible tasks) and 'testinfra' (using Python pytest)
The verify phase tests that the role achieved its intended outcome using either Ansible assertions or Python-based Testinfra tests.
How do you run Molecule tests for all roles in an Ansible collection simultaneously?
Answer: Use 'molecule test --all' within each role directory, or configure a CI matrix job that iterates over all roles and runs 'molecule test' in each
Molecule tests are role-specific; testing all roles requires scripting or CI matrix strategies that iterate over each role directory.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- redhat.com — Score release, test delivery, renewal, score validity, exam information · verified Oct 2026
- docs.redhat.com — Fees, exam format, retake policy · verified Oct 2026