← Lessons/Your First Playbook
← Your First Playbook

Explain the model

Learn

The model

You've written a play with one task that calls one module, and watched the PLAY RECAP tally it. Those three words (play, task, module) are the vocabulary of every playbook you'll read from here on.

Three more words define Ansible as a whole:

  • Declarative: you describe the destination ("this file should exist with these contents"), not the route.
  • Idempotent: running it again is safe; a playbook that's already applied changes nothing. You'll see that in action soon.
  • Agentless: nothing to install on the machines you manage; Ansible connects over SSH (here it just runs against this sandbox).

This step isn't a command: answer the questions below.

Answer the questions below about the parts of a playbook.

What does a play do?
In a task, what's the module?
Sign in to check your answers

Interview prep

The declarative vs. imperative distinction is the first thing an interviewer probes about Ansible.

How is an Ansible playbook different from a Bash script that does the same thing?

A Bash script is imperative — a list of commands that run every time, whether or not they're needed. A playbook is declarative: each task describes a desired state, and Ansible only acts when reality doesn't match. That makes it idempotent (safe to re-run) and is why it's the standard for configuration management instead of a pile of shell scripts.

$ ansible-playbook playbook.yml
Loading...

Output

Run your solution to see its output here.