The fact gathering code lives here:
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts.py