Let's suppose we have in inventory:
[centos] centos1 ansible_port=2222
ansible centos -m ping -e "ansible_port=22"