How can i get hosts variable value from ansible yaml file for a particular playbook to custom python module?

How can i get hosts variable value from ansible yaml file for a particular playbook to custom python module?

Would the custom module be apart of the same playbook that the host variable is in? Or separate?

If it apart of the same playbook My first thought is to pass the j2 host variable nto the custom python module as a parameter, if it is an Ansible module that is. Otherwise you should be able to pass it into the module as a sys.argv as well and let the custom module perform its logic from there.