Ansible and Vsphere

85 views
Skip to first unread message

Robert Williams

unread,
Feb 16, 2017, 5:03:20 PM2/16/17
to Ansible Project
All , i have searched many sites but i am able to get this playbook to work. I am trying to build a vm via ansible and i get the following error message below. I have also posted my playbook. Any help would be greatly appreciated.

Thanks in advance,

___PLAYBOOK____
---
- hosts: 127.0.0.1
  connection: local
  user: root
  sudo: false
  gather_facts: false
  serial: 1

  vars_prompt:
  - name: "pw"
    prompt: "MOAR password"
    private: yes

  tasks:
  - vsphere_guest:
      vcenter_hostname: vsphere.example.com
      username: rewilliams
      password: "{{pw}}"
      guest: testansible
      state: powered_on
      vm_disk:
        disk1:
        size_gb: 1
        type: thin
        datastore: Comoy-SAN
      vm_nic:
        nic1:
        type: vmxnet3
        network: Example_Application_10.10.10.0_24_VLAN10
        network_type: standard
      vm_hardware:
        memory_mb: 1024
        num_cpus: 1
        osid: oracleLinux64Guest
        scsi: paravirtual
      esxi:
        datacenter: Example - New City, TX
        hostname: esxsvr021.example.com

____ERROR___

task path: /etc/ansible/create_vm.yaml:15
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/cloud/vmware/vsphere_guest.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242 `" && echo ansible-tmp-1487280769.35-182699925301242="` echo $HOME/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpGFvqc6 TO /root/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242/vsphere_guest.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242/ /root/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242/vsphere_guest.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242/vsphere_guest.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1487280769.35-182699925301242/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py", line 1909, in <module>
    main()
  File "/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py", line 1880, in main
    config_check("vm_disk", vm_disk, proto_vm_disk, module)
  File "/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py", line 1646, in config_check
    if diff.recursive_diff():
  File "/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py", line 1617, in recursive_diff
    if k in self.check_dict[key]:
TypeError: argument of type 'NoneType' is not iterable
fatal: [127.0.0.1]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "vsphere_guest"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py\", line 1909, in <module>\n    main()\n  File \"/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py\", line 1880, in main\n    config_check(\"vm_disk\", vm_disk, proto_vm_disk, module)\n  File \"/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py\", line 1646, in config_check\n    if diff.recursive_diff():\n  File \"/tmp/ansible__DEP7T/ansible_module_vsphere_guest.py\", line 1617, in recursive_diff\n    if k in self.check_dict[key]:\nTypeError: argument of type 'NoneType' is not iterable\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}
        to retry, use: --limit @/etc/ansible/create_vm.retry

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=1   

Nehal J Wani

unread,
Feb 17, 2017, 2:36:12 AM2/17/17
to ansible...@googlegroups.com
Seems like there is an indentation problem. Try:

      vm_disk:
        disk1:
          size_gb: 1
          type: thin
          datastore: Comoy-SAN
      vm_nic:
        nic1:
          type: vmxnet3
          network: Example_Application_10.10.10.0_24_VLAN10
          network_type: standard

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5dc8a85c-e5aa-40e5-aaa8-d724c688a0fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Nehal J Wani
Reply all
Reply to author
Forward
0 new messages