Skip to content

Result of a playbook run

Every task in a playbook returns a state. Possible states are:

  • ok
  • changed
  • unreachable
  • failed
  • skipped
  • rescued
  • ignored
Example result of a play
PLAY RECAP *********************************************************************
server1     : ok=28   changed=1    unreachable=0    failed=0    skipped=10   rescued=0    ignored=0   
server2     : ok=26   changed=1    unreachable=0    failed=0    skipped=10   rescued=0    ignored=0   
server3     : ok=26   changed=1    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0   
server4     : ok=25   changed=1    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0   
server5     : ok=25   changed=1    unreachable=0    failed=0    skipped=7    rescued=0    ignored=0   

Based on the state you will know, if the playbook run was successful or not.

Modifing the result of a task

You can override the result of a task by using the changed_when and failed_when keywords. This can be usefull if you for example want a task to never be marked as changed.

never-change.yml
- name: Hello World
  shell:
    command: echo "hello"
  changed_when: false
change-if.yml
- name: Hello World
  shell:
    command: echo "hello"
  register: result
  changed_when: result.stdout == "hello"

Behaviour of a task on failure

If a task fails, no other task will be executed on this host. All other hosts will continue to execute their tasks.

You can change this behaviour by using the ignore_errors keyword.