Ansible -Calling a playbook inside a playbook with vars_prompt giving error : ERROR: vars_prompt is not a legal parameter in an Ansible task or handler

Looks like you are missing a tasks section and also have some indent issues.

Thanks for the quick reply. I fixed those issue, but the main problem remains. The if condition is not evaluated.
P.S: I am going off topic here, but is there any way for me to place a when condition on a complete playbook or say for the first 10 tasks in a playbook etc?

On the first part, can you show your new playbook and the output?

As to your question, yes.

  • hosts: all
    tasks:

  • group_by: key=test-{{ a > b }}

  • hosts: test-True
    tasks: # or roles, here, etc

  • ping

  • hosts: tests-False
    tasks:

  • ping

The group_by module basically carves up hosts based on arbitrary criteria, creating dynamic groups that are very useful for this sort of thing.

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

Thanks mate, I’ll give this a try!