Lesson 6 / 26

Running a Playbook and Reading the Output

Run ansible-playbook and interpret ok, changed, failed and the recap.

ok, changed, failed

ansible-playbook -i inventory.ini site.yml runs the plays. For each task and host you see ok (already correct), changed (Ansible modified something), failed or skipping. The PLAY RECAP summarises per host. A healthy repeat run shows changed=0.

First run, run for real

I ran this. The directory and both config files are created (changed), and the handler runs because the template task changed.

ansible-playbook -i inventory.ini site.yml

Output:

PLAY [Configure web servers] ***************************************************
TASK [Ensure output directory exists] ******************************************
changed: [web1 -> localhost]
TASK [Render config] ***********************************************************
changed: [web1 -> localhost]
changed: [web2 -> localhost]
RUNNING HANDLER [Reload app] ***************************************************
ok: [web1] => {
    "msg": "reloading app on web1"
}
ok: [web2] => {
    "msg": "reloading app on web2"
}
PLAY RECAP *********************************************************************
web1                       : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
web2                       : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Use -v for detail

Add -v, -vv or -vvv to see module arguments, results and connection details when a task fails and the message is not enough.

Quick check: What does "changed" mean for a task result?

  • The host is unreachable
  • The task failed
  • The task was skipped
  • Ansible modified something on the host
Answer

Ansible modified something on the host — "changed" reports that the module altered the system to reach the desired state.