【发布时间】:2016-12-03 18:09:02
【问题描述】:
我想使用 ansible_ssh_common_args 的 ProxyCommand 跳转/SSH Bastion Host。 ansible 服务器:10.10.149.2 网关/堡垒主机:10.10.149.70 主机连接:10.32.32.190 所以我的目标是从 10.10.149.2 到 10.10.149.70 连接 10.32.32.190(ssh 隧道)
ansible --version ansible 2.1.0.0
我的库存:
[local]
10.10.149.2
[Private]
10.32.32.190
[Private:vars]
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q root@10.10.149.70"'
pingtest.yml:
---
- hosts: Private
tasks:
- name: test connection
ping:
register: ping1
- debug: var=ping1
面临的问题:
fatal: [10.32.32.190]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
所以我怀疑库存文件中的 ansible_ssh_common_args 支持。我不想使用 ssh.config 文件。
日志:
[root@mavosdsc ansible]# ansible-playbook -i inventory pingtest.yml -e "user=root" --ask-pass -vvvv
Using /etc/ansible/ansible.cfg as config file
SSH password:
Loaded callback default of type stdout, v2.0
PLAYBOOK: pingtest.yml *********************************************************
1 plays in pingtest.yml
PLAY [Private] *****************************************************************
TASK [setup] *******************************************************************
<10.32.32.190> ESTABLISH SSH CONNECTION FOR USER: None
<10.32.32.190> SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.32.32.190 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1469788026.71-124524328003439 `" && echo ansible-tmp-1469788026.71-124524328003439="` echo $HOME/.ansible/tmp/ansible-tmp-1469788026.71-124524328003439 `" ) && sleep 0'"'"''
fatal: [10.32.32.190]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
to retry, use: --limit @pingtest.retry
PLAY RECAP *********************************************************************
10.32.32.190 : ok=0 changed=0 unreachable=1 failed=0
【问题讨论】:
-
请检查
-vvvv输出以了解特定的 ssh 错误。ansible_ssh_common_args在库存中应该可以正常工作。我在 ./group_vars/all.yml 中使用它没有问题。 -
任务 [设置] ****************************************** ***************************** 为用户建立 SSH 连接:无
-
[Private.vars]有错字,应该是Private:vars -
[Private] 10.32.32.190 [Private:vars] ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q root@10.10.149.70"' 我的错误并改变了它。现在也是同样的事情。我怀疑 为用户建立 SSH 连接:无
-
您还在分配中将
=更改为:- 这是不正确的,请恢复为=。
标签: ansible ansible-playbook ansible-2.x