2016-01-06 36 views
1

我目前正在嘗試編寫一本劇本來在我們的VMware羣集中部署虛擬機,但我目前處於虧損狀態。無論輸入到劇本中的是什麼,它都不會識別資源池。VMware和Ansible - 資源池?

--- 
- hosts: all 
    gather_facts: false 
    connection: local 
    user: remote 
    sudo: false 

    vars_prompt 
    - name: "resource_pool" 
     prompt: "Enter resource pool" 
     private: no 

    vars: 
    notes: 'Created by Ansible' 
    vcenter_hostname: 'esxhost.local' 
    vcenter_username: 'om' 
    vcenter_password: '*********' 

    tasks: 
    - vsphere_guest: 
     vcenter_hostname: "{{ vcenter_hostname }}" 
     username: "{{ vcenter_username }}" 
     password: "{{ vcenter_password }}" 
     guest: "{{ vm_name }}" 
     cluster: DummyCluster 
     resource_pool: "{{ resource_pool }}" 
     from_template: no 
     template_src: testvm001 
     vm_extra_config: 
      notes: "{{ notes }}" 
     vm_disk: 
      disk1: 
      size_gb: 10 
      type: thin 
      datastore: dummystore01 
     vm_nic: 
      nic1: 
      type: vmxnet3 
      network: vlan48-internal 
      network_type: standard 
     vm_hardware: 
      memory_mb: 512 
      num_cpus: 1 
      osid: ubuntu64Guest 
      scsi: paravirtual 
     esxi: 
      datacenter: DUMMY-DC 
      hostname: esxdummy01.local 

不管我如何定義資源池,它總是返回一個錯誤。在官方文檔,資源池炫耀爲被定義爲:

resource_pool: "/Resources" 

"/Resources",我認爲是資源池,儘管這樣,帶或不帶前斜線,將無法正常工作。

+0

不工作怎麼樣? Ansible錯誤嗎?還是它沒有錯誤地運行,但不會做你所期望的?如果錯誤可以顯示錯誤?另外,你是否嘗試過在任務中對resource_pool變量進行硬編碼?那是什麼結果? – ydaetskcoR

+0

Ansible返回一個錯誤,它沒有找到資源池並中止劇本工作。按照文檔中所述對值進行硬編碼會得到相同的結果,Ansible無法在DC中找到資源組。 – OliverMller

回答

2

在ServerFault上的問題中找到我的解決方案。發現你需要定義資源池的方式是使用/ Resources作爲一種目錄。

所以一臺機器添加到名爲「TestVM」資源池,你需要定義如下:

resource_pool: "/Resources/TestVM" 

希望這有助於任何人,一直在我的船。