Here's one way (assuming 0.8 syntax). Just have two short plays
that talk to each group, and use the group-exclusion features.
hosts: virt:!virt-managed
tasks:
- template: ...
hosts: virt-managed
tasks:
- template: ...
(Alternatively, create a group called virt-unmanaged, and make the
group virt contain those other two groups as child groups)
You can then, in other steps before or after, address the virt group
as a whole. Playbooks can contain as many plays as you want
so it's fine to use different hosts selectors.
I think lots of people end up getting carried away with "only_if" as a
conditional check, and that's ok, but it's usually not neccessary.
I'll leave it someone else to post the only_if version