access to ansible_ssh_host and ansible_ssh_port in a play

504 views
Skip to first unread message

Stefan Lapers

unread,
Aug 8, 2014, 3:14:39 AM8/8/14
to ansible...@googlegroups.com
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

Amr Ali

unread,
Aug 8, 2014, 9:42:32 AM8/8/14
to ansible...@googlegroups.com
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 }}
Reply all
Reply to author
Forward
0 new messages