If you’re using Ansible >2.2.0, you can set the ansible_python_interpreter configuration option to /usr/bin/python3:
ansible my_ubuntu_host -m ping -e ‘ansible_python_interpreter=/usr/bin/python3’
or in your inventory file:
[ubuntu_hosts]
hostname1
hostname2
[ubuntu_hosts:vars]
ansible_python_interpreter=/usr/bin/python3