我试图从ansible ssh到一台Windows机器,程序卡住了

时间:2016-03-08 16:31:39

标签: ssh ansible

任务:

name: Connect to Windows hpst machine through an ssh script
script : windows_connect.ssh
name: Run the bat file
script : C:\OV\sentenv.bat
name: To exit from the remote machine
shell: exit

这就是我的剧本的样子。

Windows_connect.sh包含一个通过ssh连接到Windows机器的脚本。

ssh root@host

理想情况下,ansible提示我输入密码吗? 相反它会卡住。

请帮我一样

1 个答案:

答案 0 :(得分:1)

Ansible为游戏中的每个任务打开至少一个新的ssh连接。

因此,打开与第一个任务的ssh连接然后在后续任务中重用连接的想法将无效。实际上Ansible将无法执行第一个任务,因为您尝试使用的script module已经需要与远程主机建立有效连接。

我发现很少有关于Ansible将用于执行任务的ssh连接的信息,所以我可能在这里错了。

您应该参考Ansible documentation for Window support并实施基于winrm Python模块的解决方案。