callback_plugin: get list of hosts in __init__

I am developing a custom callback plugin.

I need to know the computed list of hosts in the constructor (i.e. the __init__method of my CallbackModule).
This should be all hosts currently limited, not necessarily which hosts will actually be called in any particular play (which may vary of course).

Is this even possible to grab at that point?

The earliest you can start to get info like that is during v2_playbook_on_play_start

__init__ is run during object instantiation, which happens before a playbook and play have been parsed. Since a play is where the hosts live, you will have to wait until that point.

Ah, I was starting to trace through Ansible but hadn’t found yet where the CallBack is instantiated.

v2_playbook_on_play_start receives an arg called “play”. That gives the list of nodes as their passed into the command line; i.e. names of groups are not broken out. I’d prefer to have a list of computed hosts at some point before v2_playbook_on_stats at the very end.

this actually looks like what I’m looking for:

https://groups.google.com/d/msg/ansible-devel/DQiGednLgU0/JIvQ2Z-zFQAJ

specifically the
get_variable_manager()
method.