Interview Prep/Ansible/Testing, CI/CD and Quality

How is a Molecule scenario laid out, and what does `molecule test` actually run?

IntermediateProductionTesting, CI/CD and Quality
Answer

A scenario lives in roles/<role>/molecule/<scenario>/ and contains molecule.yml (driver, platforms, provisioner, verifier), converge.yml (applies the role), optionally prepare.yml (pre-state such as repos or users) and verify.yml (assertions).

molecule test runs the full sequence: dependency → cleanup → destroy → syntax → create → prepare → converge → idempotence → side_effect → verify → cleanup → destroy.

# molecule/default/molecule.yml
driver:
  name: docker
platforms:
  - name: rocky9
    image: geerlingguy/docker-rockylinux9-ansible:latest
    pre_build_image: true
provisioner:
  name: ansible
verifier:
  name: ansible

The idempotence step re-runs converge and fails if anything reports changed, which is the single most valuable check Molecule gives you.

All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality