Hello
I’m wondering if there is a way to determine why a task in a playbook was skipped (or not skipped). Use case would be a playbook where you have multiple conditionals (like ‘when’) defined for a task and you want to know according to ansible what caused the evaluation to pass or fail. Even though one could determine this by looking at their playbooks, as they get more complex it would be nice to rule out human error when trying to debug why something is not working.
Thanks!
Hi William,
Alas, currently no.
It’s been suggested that -v show information about what conditionals it has evaluated when things are skipped, and I can see that being a thing.
Can you give a more specific example so I can make sure I’m understanding appropriately where you might be stuck on whether it’s one conditional or another, etc?
Thanks!
Hi Michael
I think the concept you mentioned with the -v would be spot on.
An example of a situation where this would be useful is, I made a change to a playbook with an existing task where I added a conditional to that task, and also added an 2nd task with the same conditional (when). It turned out I was referencing a host_var that did not exist by mistake, but because the first task had run previously on the host I was testing, it showed status OK, whereas the second task with the same conditional showed as skipped, which led me to think there was something causing the conditional to no longer return true at that point in the playbook. If I had been able to see the conditional was never evaluated in the first place I would have noticed right away there was a problem with my host_var, and saved some troubleshooting time.
Obviously this is a nice to have, not a necessity, I was just asking in case such a feature already existed. Also I could foresee this becoming valuable in the situation where there are multiple conditionals and/or what is being evaluated is changing throughout the execution of a playbook.
Thanks for taking this into consideration!