When we run a playbook, with verbose output enabled, in the ansible logs we can see something like this:
2016-02-03 12:51:58,235 p=4105 u=root | PLAY RECAP
If you will be using the pid in different plays, just add it to the setup module.
setup
setup_result['ansible_facts']['ansible_pid'] = os.getpid()
and it will always be available.
"ansible_os_family": "Debian", "ansible_pid": 27930, "ansible_pkg_mgr": "apt",