Given that you do not use Paramiko for ssh (
transport = ssh), Ansible will fully use your
~/.ssh/config. Therefore you can globally define all connection rules in your ssh configuration.
If for some reason you want Ansible to not use your default ssh config but provide an separate configuration, you can define this in your
[ssh_connection] ssh_args= -F "/path/to/ssh/config/specifically/for/ansible"
In your ssh config then set up the connection rules. To stick with your example:
Host HostA HostName real-host-name-A.com Host HostB HostName real-host-name-B.com ProxyCommand ssh -q HostA nc %h %p Host HostC HostName real-host-name-C.com ProxyCommand ssh -q HostB nc %h %p
- Connections to A are direct
- Connections to B go through A
- Connections to C go through B, which goes through A