Error in Deploying Virtual Machines to vCenter with Ansible | Must call 'connect' before invoking this method

691 views
Skip to first unread message

tarun emany

unread,
May 21, 2015, 1:46:11 PM5/21/15
to ansible...@googlegroups.com


Hi,

While deploying new VM to vCenter using Ansible playbook I am getting the following error.

failed: [127.0.0.1] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/.ansible/tmp/ansible-tmp-1432176296.75-239675909842816/vsphere_guest", line 2923, in <module>
    main()
  File "/.ansible/tmp/ansible-tmp-1432176296.75-239675909842816/vsphere_guest", line 1312, in main
    state=state
  File "/.ansible/tmp/ansible-tmp-1432176296.75-239675909842816/vsphere_guest", line 901, in create_vm
    task.get_error_message())
  File "/usr/local/lib/python2.7/dist-packages/pysphere/vi_task.py", line 82, in get_error_message
    self.__poll_task_info()
  File "/usr/local/lib/python2.7/dist-packages/pysphere/vi_task.py", line 120, in __poll_task_info
    raise e
pysphere.resources.vi_exception.VIException: [Not Connected]: Must call 'connect' before invoking this method


FATAL: all hosts have already failed -- aborting

I have installed pysphere and created following yml and tried execution.

My playbook.yml is

- hosts: 127.0.0.1
  connection: local
  user: root
  sudo: false
  gather_facts: false
  serial: 1
  tasks:
  - vsphere_guest:
      vcenter_hostname: xxxxxx
      username: xxxxx
      password: xxxx
      guest: SampleVM
      state: powered_on
      vm_extra_config:
        vcpu.hotadd: yes
        mem.hotadd:  yes
        notes: This is a test VM
      vm_disk:
        disk1:
          size_gb: 10
          type: thin
          datastore: xxxxxx
      vm_nic:
        nic1:
          type: vmxnet3
          network: vm
          network_type: standard
      vm_hardware:
        memory_mb: 1024
        num_cpus: 1
        osid: UbuntuLinux
        scsi: paravirtual
      esxi:
        datacenter: xxxxxx
        hostname: xxxxx


Please help me out.

Mikhail Koshelev

unread,
May 21, 2015, 7:26:45 PM5/21/15
to ansible...@googlegroups.com
Hi Tarun,

Most probably you have some issue with provided configuration parameters for VM.  From my experience, "Must call 'connect' before invoking this method" is a generic error reported by vsphere_guest module when VMware is unable to create the VM.
To see what exactly is wrong - connect to your target vCenter (or ESXi) server with vSphere client and check the tasks status panel when running the playbook. The error message there usually shows a clue on what item in VM configuration causes error.

tarun emany

unread,
May 21, 2015, 7:30:39 PM5/21/15
to ansible...@googlegroups.com
Thanks Mikhail,

It was a configuration issue.The osid is given wrong. It worked after changing to ubuntu64Guest.

Gallo

unread,
Aug 18, 2016, 4:29:23 PM8/18/16
to Ansible Project
Yep, had the same problem. Same solution the "osid"
Reply all
Reply to author
Forward
0 new messages