0Pricing
Ansible Academy · Lesson

Run It with ansible-playbook

Execute and read the play output.

Run It with ansible-playbook is a free Ansible Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The ansible-playbook Command

You run a playbook with the ansible-playbook command, not plain ansible. Pass it the YAML file you want to execute.

ansible-playbook site.yml

Point It at Your Inventory

Use -i to choose which inventory file lists your hosts. Without it, Ansible falls back to its default inventory.

ansible-playbook -i inventory.ini site.yml

Gathering Facts First

The first thing you see is the Gathering Facts task. Ansible collects details about each host before running your tasks.

TASK [Gathering Facts] *********

Reading the Task Lines

Each task prints a status per host. You will see ok, changed, or failed, telling you exactly what happened.

TASK [start nginx] *********
changed: [web1]

ok Means No Change

A green ok means the host was already in the desired state. Ansible checked it and decided nothing needed to change.

changed Means It Acted

A yellow changed means Ansible actually altered the host to match what you asked for. That is real work being done.

The PLAY RECAP

At the end, the PLAY RECAP summarizes every host: how many tasks were ok, changed, unreachable, or failed.

PLAY RECAP *********
web1 : ok=2 changed=1 failed=0

failed and unreachable

A nonzero failed means a task errored on that host. unreachable means Ansible could not even connect over SSH.

Add Verbosity With -v

Stuck on an error? Add -v for more detail. Stack more v's, up to -vvvv, to see ever deeper debugging output.

ansible-playbook site.yml -vv

Syntax Check Before You Run

Catch YAML mistakes early with --syntax-check. It parses the playbook without touching any host.

ansible-playbook site.yml --syntax-check

Limit to One Host

Testing on a single machine first? Use --limit to run the play against just one host before rolling it out wide.

ansible-playbook site.yml --limit web1

Quick Check

A task shows changed on a host. What does that mean?

You Can Run and Read Plays

You now launch playbooks with ansible-playbook and read the recap. ok, changed, and failed tell the whole story. ✅

Frequently asked questions

Is the “Run It with ansible-playbook” lesson free?

Yes — the full text of “Run It with ansible-playbook” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.

What will I learn in “Run It with ansible-playbook”?

Execute and read the play output. You practise Ansible Academy 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 Ansible Academy?

No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Run It with ansible-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 Ansible Academy lesson?

Yes. Every Ansible Academy 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 Ansible Academy