From f279ce5209388632b6043b3a0476c0cb15aa3fb7 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Sat, 11 May 2019 11:58:13 +0530 Subject: [PATCH] [2.8] VMware: vmware_guest_disk support for use_instance_uuid All vmware_guest_* module support for use_instance_uuid from Ansible 2.8, somehow vmware_guest_disk missed from this change. This fix adds support for use_instance_uuid in vmware_guest_disk. Fixes: #56021 Signed-off-by: Abhijeet Kasurde (cherry picked from commit 7e6be4e634c08dfdc5fd9692533bcc52a5e25917) --- .../56021-vmware_guest_disk-use_instance_uuid.yml | 2 ++ lib/ansible/module_utils/vmware.py | 6 +++--- lib/ansible/modules/cloud/vmware/vmware_guest_disk.py | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/56021-vmware_guest_disk-use_instance_uuid.yml diff --git a/changelogs/fragments/56021-vmware_guest_disk-use_instance_uuid.yml b/changelogs/fragments/56021-vmware_guest_disk-use_instance_uuid.yml new file mode 100644 index 00000000000..86414b3f404 --- /dev/null +++ b/changelogs/fragments/56021-vmware_guest_disk-use_instance_uuid.yml @@ -0,0 +1,2 @@ +minor_changes: +- vmware_guest_disk module supports use_instance_uuid parameter since Ansible 2.8 (https://github.com/ansible/ansible/issues/56021). \ No newline at end of file diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 9d5b08239e9..4a7eb62cdc2 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -880,10 +880,10 @@ class PyVmomi(object): """ vm_obj = None user_desired_path = None - - if self.params['uuid'] and not self.params['use_instance_uuid']: + use_instance_uuid = self.params.get('use_instance_uuid') or False + if self.params['uuid'] and not use_instance_uuid: vm_obj = find_vm_by_id(self.content, vm_id=self.params['uuid'], vm_id_type="uuid") - elif self.params['uuid'] and self.params['use_instance_uuid']: + elif self.params['uuid'] and use_instance_uuid: vm_obj = find_vm_by_id(self.content, vm_id=self.params['uuid'], vm_id_type="instance_uuid") diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_disk.py b/lib/ansible/modules/cloud/vmware/vmware_guest_disk.py index 9a7956d0b3e..ace0da27840 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_disk.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_disk.py @@ -60,6 +60,12 @@ options: description: - The datacenter name to which virtual machine belongs to. required: True + use_instance_uuid: + description: + - Whether to use the VMWare instance UUID rather than the BIOS UUID. + default: no + type: bool + version_added: '2.8' disk: description: - A list of disks to add. @@ -630,6 +636,7 @@ def main(): folder=dict(type='str'), datacenter=dict(type='str', required=True), disk=dict(type='list', default=[]), + use_instance_uuid=dict(type='bool', default=False), ) module = AnsibleModule(argument_spec=argument_spec, required_one_of=[['name', 'uuid']])