Ansible vmware_guest 无法通过 ssh 进入 vmware vSphere vCenter

Ansible vmware_guest cannot ssh into vmware vSphere vCenter

我正在尝试使用 ansible 设置虚拟机。但是,ansible 一直卡在 Deploy guest from template 任务上。

使用-vvv,我得到了以下日志。

尝试通过 ssh 公钥身份验证登录时:

TASK [Deploy guest from template] 

task path: /home/wilb/Development/vcenter_demo/vcenter_demo.yml:12
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest.py
<vcenter.mycompany.com> ESTABLISH SSH CONNECTION FOR USER: root
<vcenter.mycompany.com> SSH: EXEC ssh -C -o ControlMaster=auto 
  -o ControlPersist=60s -o KbdInteractiveAuthentication=no 
  -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
  -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 
  -o ControlPath=/home/wilb/.ansible/cp/982c3c15ab 
  vcenter.mycompany.com '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''

当我尝试使用 --ask-pass 时,它卡在了这里:

TASK [Deploy guest from template] *******************************************************************************************************
task path: /home/wilb/Development/vcenter_demo/vcenter_demo.yml:14
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest.py
<vcenter.mycompany.com> ESTABLISH SSH CONNECTION FOR USER: root
<vcenter.mycompany.com> SSH: EXEC sshpass -d12 ssh -C 
  -o ControlMaster=auto -o ControlPersist=60s -o User=root 
  -o ConnectTimeout=10 
  -o ControlPath=/home/wilb/.ansible/cp/982c3c15ab 
  vcenter.mycompany.com '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''

我可以手动登录vCenter。但是,要访问 shell,我首先必须在 vCenter 中键入:"shell";默认情况下,它是一些奇怪的自定义提示。

如何让 ansible 正确登录到 vcenter 以自动部署 VM?

系统

Ansible vmware_guest cannot ssh into vmware vSphere vCenter

不应该。

您应该从本地计算机调用大部分 "cloud" 模块。
看看 vmware_guest 的例子:到处都是 delegate_to: localhost