举个例子
A需要登录C,C没有公网,B有公网地址,B和C在同一个内网。
# cat /etc/ansible/hosts2
[aaa]
aaa ansible_ssh_host=10.28.111.11 ansible_ssh_port=14573
[bbb]
bbb ansible_ssh_host=10.47.111.11 ansible_ssh_port=14573
# cat /etc/ansible/group_vars/aaa.yml
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q 用户@公网IP -p14573"'
# cat /etc/ansible/group_vars/bbb.yml
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q 用户@公网IP -p14573"'
ansible-client机器都要有ansible-server的公钥,跳板机也要