This is a bit like the XY problem , but one option would be to start the shell using the command shelland then request the parent PID:
- name: get pid of playbook
shell: |
echo "$PPID"
register: playbook_pid
This will give you the PID of the process pythonthat runs the game.