Skip task in callback_plugin or stop playbook execution

I would like to skip a task or all tasks conditionally in my callback_plugin. Is that possible? I am trying to implement a stop playbook feature where I query an external API in my callback_plugin, and if a stop flag is raised, I would like to skip all remaining tasks in the playbook or simply kill the playbook after the current running task. Note, I need to wait for the current running task to finish before exiting the playbook. Appreciate any ideas.

Is this called before or after the task has actually started?

def v2_playbook_on_task_start(self, task, is_conditional):
    

Did some more reading and found out action_plugin may be the right way to go. Can we have a global action_plugin that runs before all module executions? So that I can check for a skip flag and skip module executions?

Please advise if there is a better way of going about this.

Thanks

make your first action

  • meta: end_play
    when: ???

http://docs.ansible.com/ansible/meta_module.html

Thanks Brian. But wouldn’t I need to include this between every task in my play? Is there a better way to stop my playbook execution from a callback_plugin or an action_plugin based on a condition?

Thanks