Specific playbook actions only when host is in other hostgroup

only_if: "'$inventory_hostname' in ${groups.groupname}" seems to be
what you want.

Deep down in the mailinglist I found:

only_if: “‘groupname’ in $group_names”

And the response below from Serge also states that. Why is your different, except for there being multiple ways to Rome? Which is (more) correct, and why?

They are just inverted ways of saying the same thing.

Ok!

Is it possible to get the only_if statement working with a “- include playbook.yml” directive?

- include: foo
  only_if: blarg

will attach the blarg on task includes.

It doesn't make any sense for playbook includes, as conditionals are
not applied to whole playbooks, but to tasks.