I'm currently attempting to write a playbook to deploy virtual machines in our VMware cluster, and I'm currently at a loss. No matter what is being input into the playbook, it will not recognize the resource pool.
---
- 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
No matter how I define the resource pool, it always returns an error. In the official documentation, resource pools are shown off as being defined:
resource_pool: "/Resources"
Where "/Resources"
, I assume is the resource pool, though this, with or without front slash, will not work.
Found my solution in a question on ServerFault. Turns out the way you need to define the resource pool is using /Resources as a kind of directory.
So to add a machine to the resource pool named 'TestVM', you would need to define the following:
resource_pool: "/Resources/TestVM"
Hope this helps anyone that's been in my boat.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.