Iterate through every group/host pair but won't work with 'groups'

I don’t think Ansible will work with this scenario.

I want to iterate through every ansible role and host as a flat index.

Right now the groups variable is what I’m focused on. Which is:

group0:

  • host0

  • host1

group1:

  • host2
  • host3

I want to process it as:

group0, host0
group0, host1
group1, host2
group1, host3

… but I don’t think this is possible. Is there a ‘flatten’ I can use?

with_dict and with_subelements won’t work.

with_subelements complains that it expects a map with a key to iterate from.