Here are three methods to get the UID and GID for the default ansible user.
With Ansible facts
If you don't disable fact gathering, then your ansible run will have a variable ansible_facts. In this case, you can get the UID and GID directly from it:
-