On a related note are there any plans for checking for certain features and conditionally executing large parts of playbooks? (Or it should be achieved via variables?)
My use case is very similar, but sometimes checking whether a certain software is available is a bit more complex than just looking for a file. (Then comparing versions might require other trickery.) Plus using creates=… seems rather cumbersome instead of some nice YAML structure, also it could speed up playbook execution (which is always a good thing in my book, especially for pull-based mode) by leaving out most part.
On a related note are there any plans for checking for certain features and conditionally executing large parts of playbooks? (Or it should be achieved via variables?)
only_if can use variables to keep from copy/pasting the expression.
Tip though – If you want to apply certain things to certain classes of hosts it’s better to use groups for that than detection, i.e. “put php on hosts where I have apache” is troublesome rather than saying explicitly, “on these hosts I want apache + php”
Make a group called “php_servers” in this case, and then you can avoid using only_if at all, etc.
My use case is very similar, but sometimes checking whether a certain software is available is a bit more complex than just looking for a file. (Then comparing versions might require other trickery.) Plus using creates=… seems rather cumbersome instead of some nice YAML structure, also it could speed up playbook execution (which is always a good thing in my book, especially for pull-based mode) by leaving out most part.
This is not too terrible if you write a custom module that returns an “ansible_facts” dictionary, and you can then use that custom fact in only_if expressions.
(This is more or less how you have to do it in Puppet land, and I’m okay with it being a little clunky as I suspect most people won’t need to do it that way.)