DevOps Bootcamp · Lesson

From Ad-Hoc to a Repeatable Playbook

Turn commands into a saved YAML file.

Lesson 2 of 413 steps

From Ad-Hoc to a Repeatable Playbook 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.

Ad-Hoc Commands Vanish

An ad-hoc command runs once and is gone. It is great for quick checks, but it leaves no record of what you did.

ansible web -m service -a "name=nginx state=started"

A Playbook Is Saved Work

A playbook writes that same intent into a YAML file. You commit it, share it, and run it again whenever you need.

One Command Maps to One Task

Each ad-hoc command becomes a single task in the playbook. The module and its arguments carry straight over.

- name: start nginx
  service:
    name: nginx
    state: started

A Play Wraps Your Tasks

Tasks live inside a play. The play says which hosts to target, then lists the tasks to run on them.

- hosts: web
  tasks:
    - name: start nginx
      service:
        name: nginx
        state: started

The hosts Line

The hosts key replaces the host pattern you typed on the command line. It picks the group the play will manage.

- hosts: web

Module Args Become Keys

The key=value arguments from your command turn into indented YAML keys under the module name. Same data, clearer shape.

service:
  name: nginx
  state: started

Repeatable Means Reliable

Because the file never changes, every run does exactly the same thing. This repeatability is what makes automation trustworthy.

Self-Documenting Automation

A playbook also documents your infrastructure. Reading the file tells the next person exactly how the server should be configured.

Add a Second Task Easily

Growing the file is simple: add another dash under tasks. Ad-hoc forces a new command, but a playbook just keeps the list.

tasks:
  - name: start nginx
    service:
      name: nginx
      state: started
  - name: open firewall
    debug:
      msg: done

Version Control It

Save the playbook in Git like any code. Now your server config has history, review, and the ability to roll back changes.

Name the File .yml

By convention a playbook file ends in .yml or .yaml. The name is up to you, like site.yml or webservers.yml.

Quick Check

Why move a working ad-hoc command into a playbook?

From One-Off to Forever

You turned a throwaway command into a saved playbook: a host, a task, and a repeatable record of how your server runs. 🚀

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 “From Ad-Hoc to a Repeatable Playbook” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “From Ad-Hoc to a Repeatable Playbook”, 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 “From Ad-Hoc to a Repeatable Playbook”?

Turn commands into a saved YAML file. 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 “From Ad-Hoc to a Repeatable Playbook” 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. YAML Syntax You Need for Ansible
  2. From Ad-Hoc to a Repeatable Playbook
  3. Run It with ansible-playbook
  4. Install Nginx in Five Lines
← Back to DevOps Bootcamp