I’m really puzzled by how a certain Ansible feature appears to work, and I can’t figure out why anyone in the world would ever want it to work that way. I hope that I’m just densely mis-interpreting how it works.
It seems that the when: attribute for the include: task doesn’t actually constrain when the specified playbook is included. Rather, the specified playbook is always included, and every task within the playbook is executed, with the original when: clause applied to the task.
This doesn’t make any sense whatsoever. I cannot think of a single use case for this.
On the one hand, if when: evaluates to false, then every task within the playbook will be skipped. If it evaluates to true, every task within the playbook will be executed. That sounds like a really stupid alternative to only including the playbook when when: evaluates to true. In fact, this implementation actually prevents us from conditionally including a playbook only if it hasn’t been included before, which seems like a really useful feature in general, and one of the strategies I was hoping to use in order to compensate for Ansible’s really terrible lack of composable language constructs.
What am I missing?