# count number of plays/tasks before & during run

**URL:** <https://forum.ansible.com/t/count-number-of-plays-tasks-before-during-run/23816>\
**Category:** Ansible Developer\
**Created:** [February 24, 2017, 11:37pm UTC](https://forum.ansible.com/t/count-number-of-plays-tasks-before-during-run/23816 "2017-02-24T23:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [February 24, 2017, 11:37pm UTC](https://forum.ansible.com/t/count-number-of-plays-tasks-before-during-run/23816/1 "2017-02-24T23:37:48Z")

</div>

I have a use case to monitor very long running plays over very slow, latent links. I would like to do a pre-run check, calculating how many plays, and tasks within each play, are going to run. The closest it seems is currently possible is to run --check and do a simple regex on the output. However, this takes quite some time, as all modules that support check mode will actually need to do work to determine what would change.

I would like to hook into Ansible to run each play and task, but not actually executing any modules; along the way, I’ll count and set an attribute that I can read later and display to determine how many tasks we’ve seen, and how many are left to go.

I’m not sure where in the code to start looking. I’d also like to try to make this a plugin(not sure if possible), as forking the all of ansible and trying to keep it in sync just sounds wrong.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 24, 2017, 11:43pm UTC](https://forum.ansible.com/t/count-number-of-plays-tasks-before-during-run/23816/2 "2017-02-24T23:43:50Z")

</div>

You want --sytnax-check, but that will only give you an approximation  
as dynamic includes and include\_role can change the number of tasks,  
as can tags and conditionals.

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [February 24, 2017, 11:49pm UTC](https://forum.ansible.com/t/count-number-of-plays-tasks-before-during-run/23816/3 "2017-02-24T23:49:32Z")

</div>

Ah thanks! running --syntax-check with -vv definitely gives me a starting point. Thanks!
