2017-07-26 72 views
1

我正嘗試在使用完整的操作手冊的獨立ESXi主機上創建虛擬機。 我在以下鏈接中看到,我們可以使用「ha-datacenter」作爲數據中心名稱,以便在獨立ESXi主機上創建虛擬VM。如何使用vsphere_guest Ansible模塊在獨立ESXi主機上創建虛擬機

Can I manage guest VMs in vSphere free using Ansible without vCenter?

但是我得到試圖運行的劇本 請告知

Error 
[Parameter Error]: 'host' should be a string with the ESX/VC url 

按照以下錯誤是劇本內容

--- 
- hosts: localhost 
    connection: local 
    gather_facts: no 
    vars_prompt: 
    - name: myuser 
    prompt: Enter the UserName 
    private: no 
    - name: mypass 
    prompt: Enter the Password 
    - name: vc_name 
    prompt: Enter the vCenter/ESXi HostName 
    private: no 
    - name: guest_name 
    prompt: Enter the Guest VM Name 
    private: no 
    remote_user: root 

    tasks: 
    - name: Create a VM 
    delegate_to: localhost 
    vsphere_guest: 
#  vcenter_hostname: '{{vc_name}}' 
     esxi: 
     datacenter: ha-datacenter 
     hostname: '{{vc_name}}' 
     username: '{{myuser}}' 
     password: '{{mypass}}' 
     validate_certs: no 
     guest: '{{guest_name}}' 
     state: powered_on 
     vm_extra_config: 
     vcpu.hotadd: yes 
     mem.hotadd: yes 
     notes: This is a test VM created using Ansible 

     vm_disk: 
     disk1: 
      size_gb: 100 
      type: thin 
      datastore: datastore1 
     vm_nic: 
     nic1: 
      type: vmxnet3 
      network: VM Network 
      network_type: standard 
     vm_hardware: 
     memory_mb: 2048 
     num_cpus: 2 
     osid: rhel6_64Guest 
     scsi: paravirtual 
     vm_cdrom: 
      type: "iso" 
      iso_path: "iso/rhel6.iso" 

輸出

Wed Jul 26 05:35:36 [email protected]:~/vmware$ ansible-playbook vmcreate.yml 
Enter the UserName: root 
Enter the Password: 
Enter the vCenter/ESXi HostName: 10.1.1.1 
Enter the Guest VM Name: ansible-test-vm 

PLAY [localhost] *************************************************************** 

TASK [Create a VM] ************************************************************* 
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: pysphere.resources.vi_exception.VIException: [Parameter Error]: 'host' should be a string with the ESX/VC url. 
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_SE0C2e/ansible_module_vsphere_guest.py\", line 1879, in <module>\n main()\n File \"/tmp/ansible_SE0C2e/ansible_module_vsphere_guest.py\", line 1748, in main\n viserver.connect(vcenter_hostname, username, password)\n File \"/usr/lib/python2.6/site-packages/pysphere/vi_server.py\", line 71, in connect\n ,FaultTypes.PARAMETER_ERROR)\npysphere.resources.vi_exception.VIException: [Parameter Error]: 'host' should be a string with the ESX/VC url.\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false} 

NO MORE HOSTS LEFT ************************************************************* 
[WARNING]: Could not create retry file 'vmcreate.retry'.   [Errno 2] No such file or directory: '' 


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

Wed Jul 26 05:35:58 [email protected]:~/vmware$ 
從評論
+0

劇本內容。 https://pastebin.com/sQ2XMBXe –

+0

您也可以在SO上格式化代碼塊,查看我的編輯。爲什麼'vcenter_hostname'被註釋掉了? –

+0

嗨康斯坦丁,這是問題。我的收入是vcenter_hostname,而不是ip我給了esxi的主機名,它的工作 –

回答

0

答:

爲什麼vcenter_hostname被註釋掉?

-

那是問題,而不是IP我給的ESXi主機名和它在一個更好的格式工作

相關問題