hostvar from group and with_items (without templating)

I couldn’t find a clear answer for this one in the docs and I figured I’d investigate before I revert to templating (which in this particular case is my least-preferred option). I’ve been quite lazy so far and not actually tried this yet.

I have a number of host groups in the inventory and I need to run a command on one host which uses inventory information (specifically IP address) from hosts in another group. What’s more, this is across plays in a top-level playbook. I could template this per the documentation examples but I’d like to be able to get something like:

  • name: register my systems
    action: command blabla --include $item.ansible_${interface}.ipv4.address
    with_items: ${groups.group1}

Is such a thing supposed to work?

Thanks as always :slight_smile: