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

How do you keep Molecule runs fast in CI?

IntermediateProductionTesting, CI/CD and Quality
Answer
  1. Use prebuilt images with Python and systemd already installed (pre_build_image: true), not a Dockerfile built on every run.
  2. Run only the scenarios of roles that changed: compute changed paths with git diff --name-only origin/main... and feed the list to a CI matrix.
  3. Run platforms and roles in parallel jobs rather than one long job.
  4. Cache Galaxy collections (~/.ansible/collections) and pip wheels between jobs.
  5. Keep prepare.yml small; bake slow prerequisites into the test image.
  6. Use molecule converge and molecule verify locally during development, and the full molecule test only in CI.

A role test that takes 15 minutes gets skipped by humans. Under 3 minutes it gets run.

All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality