Ansible vmware_guest cannot ssh into vmware vSpher

2019-03-07 01:35发布

I'm trying to setup a virtual machine with ansible. However, ansible keeps getting stuck on the Deploy guest from template task.

Using -vvv, I got the following logs.

When attempting to log in via ssh pubkey auth:

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'"'"''

When I try to use --ask-pass, it gets stuck here:

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'"'"''

I can login to the vCenter manually. However, to access the shell, I first have to type: "shell" in the vCenter; by default it's some weird customized prompt.

How can I get ansible to log into vcenter properly to automatically deploy a VM?

System

  • Controller OS: Fedora 26
  • Ansible: 2.4.1
  • vCenter: 6.5.0.1000

1条回答
姐就是有狂的资本
2楼-- · 2019-03-07 02:15

Ansible vmware_guest cannot ssh into vmware vSphere vCenter

It should not.

You should call most of "cloud" modules from local machine.
Take a look at examples of vmware_guest: there's delegate_to: localhost everywhere.

查看更多
登录 后发表回答