I'd tend to say that your approach isn't the best use of Ansible, as,
whichever solution you'll find, you'll end with a lot of skipped tasks in
your output, making it difficult to understand what is happening.
This said, you could split each snippet in two snippets, where the first
one is included by your big playbook and includes the 2nd one only "when"
it fits.
But again, re-think your approach, it doesn't sound like a good idea:
- roles have been invented for a reason...
- I always try to replace the typical `include/when: somevariable has
somevalue` pattern with `include {{somevariable}}.yml` to avoid all those
skips.
KR, Eric
On Thursday, 24 January 2019 16:50:33 UTC+1, Josef Fortier wrote:
>
> I've developed a style where I use a lot of includes of small snippets to
> assemble bigger plays.
> I'd like to be able to do a test a condition at the top of an include, and
> skip the rest of the include if the condition is not met.
> I know I can do this with blocks, but a "return" or "continue" style
> function is quicker (and probably slightly more readable).
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4642bf3d-c321-4a0e-b9f2-7c00a55a0aaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.