DevOps Bootcamp · Lesson

molecule init & the Scenario Layout

Scaffold a test harness for a role.

Lesson 2 of 413 steps

molecule init & the Scenario Layout is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

Scaffold a Test Harness

The molecule init command generates a ready-to-run test setup so you do not write boilerplate by hand.

Init Inside a Role

Run init from your role's root to add a scenario without touching your existing tasks or handlers.

molecule init scenario

What Is a Scenario?

A scenario is one complete test configuration: which host to create, how to run the role, and how to verify it.

The default Scenario

Init creates a folder named default under molecule/. It is the scenario that runs when you do not name another.

molecule/
  default/

molecule.yml: The Brain

The molecule.yml file wires together the driver, platforms, provisioner, and verifier for this scenario.

molecule/default/molecule.yml

Pick a Driver & Platform

The platforms block lists test hosts. With the Docker driver you just name a base image to spin up.

platforms:
  - name: instance
    image: ubuntu:22.04

converge.yml Applies Your Role

The converge.yml playbook is what actually runs your role against the test host during a test.

- hosts: all
  roles:
    - role: my_role

verify.yml Checks the Result

A verify.yml playbook holds your assertions: it confirms the role left the host in the state you expect.

molecule/default/verify.yml

Multiple Scenarios

You can add more named scenarios beside default, for example to test the same role on a second OS image.

molecule init scenario centos

Target One Scenario

Use the -s flag to run a specific scenario by name instead of the default one.

molecule test -s centos

Commit the Scenario

The whole molecule/ folder is plain text. Commit it to Git so every teammate runs the exact same test setup.

Quick Check

Recall which file configures a Molecule scenario.

Recap

molecule init scenario scaffolds a default scenario: molecule.yml configures it, converge.yml applies the role, verify.yml asserts the result. 🗂️

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “molecule init & the Scenario Layout” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “molecule init & the Scenario Layout”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “molecule init & the Scenario Layout”?

Scaffold a test harness for a role. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “molecule init & the Scenario Layout” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why Test Infrastructure Code
  2. molecule init & the Scenario Layout
  3. Converge, Verify & the Test Matrix
  4. Idempotence & Lint in the Pipeline
← Back to DevOps Bootcamp