port in ansible facts?

Hello,

Is it possible to know what port has been used for the Ansible connection on the remote node. I don’t know if this information is available.

When running with -vvv that data is shown on screen.

-jlk

I would like to be able to access this information from a playbook too.

SSH_CLIENT or SSH_CONNECTION env variables on target host should have that info.

ansible_ssh_port might get that for you.

http://www.ansibleworks.com/docs/patterns.html#list-of-reserved-inventory-parameters

-jlk

Thank you.