TASK [add disk space] *************************************************************************************************** fatal: [cl1vinfspt1000 -> localhost]: FAILED! => {"changed": false, "msg": "Please specify 'unit_number' under disk parameter at index [0], which is required while creating disk."}
The number of disks on the vms which need disk additions is going to vary - in fact, some may even have multiple controllers. I’ve used govc to add disks to vms and it just tacks the disk on the end of the bus.
So, two questions:
Is there a way to tell vmware_guest_disk to use the next available unit number?
Failing that, is there a clever way to identify the next available scsi unit number? I’m even willing to use OS commands and create a variable… interesting thought, that. I’ll look there next.
name: Get all disks in all controllers
vmware_guest_disk_info:
validate_certs: False
hostname: ‘{{ vcenter_hostname }}’
username: ‘{{ vcenter_username }}’
password: ‘{{ vcenter_password }}’
datacenter: Asia-Datacenter1
name: VM_8046
register: existing_disk
name: Create a dict with controller and the total number of disks
set_fact:
disk_info: “{{ disk_info | default({}) | combine({ item.value.controller_bus_number : item.value.unit_number} )}}”
with_dict: “{{ existing_disk.guest_disk_info }}”
debug:
msg: “{{ disk_info }}”
Here, I am iterating over all disks and controllers in the given VM. I get a final count of all disks available on each controller in disk_info dictionary. Once I have that information I can figure out what is next disk in the given controller.
Wow; that’s going to take some time to unwrap. I haven’t done much with lookups yet. I have more than a few use cases for them so it’s probably about time.
I worked around the problem by using a script task to send a short script to the host which parses info under /sys/class::
That works and got me around the issue but definitely not the cleanest approach.
While I got you, sir, thank you for the efforts on the vmware modules. So far, without exception, they’ve worked like champs. They are helping me avoid logging into vsphere even more than the limited times I do now so that’s all to the good.