# access to ansible\_ssh\_host and ansible\_ssh\_port in a play

**URL:** <https://forum.ansible.com/t/access-to-ansible-ssh-host-and-ansible-ssh-port-in-a-play/15887>\
**Category:** Ansible Project\
**Created:** [August 8, 2014, 7:14am UTC](https://forum.ansible.com/t/access-to-ansible-ssh-host-and-ansible-ssh-port-in-a-play/15887 "2014-08-08T07:14:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Lapers](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stefan\_Lapers](https://forum.ansible.com/u/Stefan_Lapers)\
**Post date:** [August 8, 2014, 7:14am UTC](https://forum.ansible.com/t/access-to-ansible-ssh-host-and-ansible-ssh-port-in-a-play/15887/1 "2014-08-08T07:14:39Z")

</div>

Hi,

Is it possible to access ansible\_ssh\_host (and other inventory parameters) in a playbook ?  
The goal is to copy/backup files _from_ a remote machine to the local ansible station or a machine specified with delegate\_to using rsync over ssh. So i would need to expand the ssh connection info in the command.

Or is an action plugin the only way to make this kind of functionality possible ?

Thanks,  
Stefan

---

<div class="post-metadata">

**Author:** ![Amr\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Amr\_Ali](https://forum.ansible.com/u/Amr_Ali)\
**Post date:** [August 8, 2014, 1:42pm UTC](https://forum.ansible.com/t/access-to-ansible-ssh-host-and-ansible-ssh-port-in-a-play/15887/2 "2014-08-08T13:42:32Z")

</div>

yes you can use hostvars, hostvars[host][‘ansible\_ssh\_host’] replacing host with the host you want to get in info on.

also ansible\_ssh\_host is available as a variable for the current play host, you can simply do {{ ansible\_ssh\_host }}
