A way to get list of hosts after limiting with '--limit' or 'serial'

Hi,

I am looking for a way to get a list of hosts on which the playbook is being executed after limiting original inventory with ‘–limit’ flag or ‘serial’ command in the playbook.

I have found that it is possible to get all the hosts in a particular group by accessing ‘groups[‘my_group’]’ variable. But the contents of this dictionary does not change when using ‘–limit’ or ‘serial’.

Is there a way to achieve this with the current code? If not I will start looking into implementing it and posting a pull request.

Martynas