Repository: ansible-collections/community.vmware

Issue:
Feature: vmware_guest_tools_upgrade to be applied without forcing reboot
<!--- Verify first that your feature was not already discussed on GitHub -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Describe the new feature/improvement briefly below -->
vmware_guest_tools_upgrade should support shutdown as an option

##### ISSUE TYPE
- Feature Idea
- Users may wish to apply the latest vmtools without rebooting immediately.

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
- https://github.com/ansible-collections/community.vmware/blob/main/plugins/module_utils/vmware.py#L968

##### ADDITIONAL INFORMATION
<!--- Describe how the feature would be used, why it is needed and what it would solve -->
- This allows the flexibility to set the desired state and then schedule the reboot in a production environment.
<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- name: Upgrade VMtools
  hosts: "{{ ansible_hosts }}"
  gather_facts: false
  become: true
  tasks:

    - name: Upgrade VMtools
      community.vmware.vmware_guest_tools_upgrade:
        hostname: "{{ vcenter_url }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        datacenter: "{{ datacenter_name }}"
        name: "{{ inventory_hostname.split('_')[0] }}"
        validate_certs: "{{ vcenter_cert_validation }}"
        allow_reboot: false
      become: false
      delegate_to: localhost
```

<!--- HINT: You can also paste gist.github.com links for larger files -->



Discussion:
Files identified in the description:
None

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
Thanks, @git-cgallagher for requesting the feature.

As far as I understand, the module doesn't automatically reboot a virtual machine after updating the guest tools.  
I tried in the following environment.

* vCenter/ESXi 6.7
* Windows 2021 R2(Guest OS)

I’d like to confirm, is this requesting for adding reboot processing to the module?
@sky-joker It's been awhile since I tested it, I'll try something in my lab and just confirm. Perhaps then we just need to update documentation in the module readme.
`This module upgrades the VMware Tools on Windows and Linux guests and reboots them.`

Hi @git-cgallagher
Are you interested in making PR to resolve if updating the document needs?
@sky-joker Hopefully I'll get a chance to confirm and then yes, happy to adjust as necessary.
Can confirm that this module forces a reboot after installing the vmware-tools, both from using this module to also reading the synopsis of this module:

```
This module upgrades the VMware Tools on Windows and Linux guests and reboots them.
```

I would also like to not force a reboot. My criteria for not wanting to force a reboot is that I use ansible to provision VM's after creating them with packer, and rebooting the VM while the ansible provisioner is waiting for ansible to return eventually makes [packer](https://www.packer.io/plugins/provisioners/ansible/ansible) time-out due to the VM having been rebooted.
I also need such optional parameter.
It would be nice to see this feature in future versions of ollection.
Hi there,
I'm also looking forward this functionality to avoid another reboot during my vm provision workflow.
+1 looking for this functionality.

Resolving patch:
diff --git a/plugins/modules/vmware_guest_tools_upgrade.py b/plugins/modules/vmware_guest_tools_upgrade.py
--- a/plugins/modules/vmware_guest_tools_upgrade.py
+++ b/plugins/modules/vmware_guest_tools_upgrade.py
@@ -70,6 +70,12 @@
         default: false
         type: bool
         required: false
+   installer_options:
+        version_added: '4.1.0'
+        description:
+            - Command line options passed to the installer to modify the installation procedure for tools.
+        type: str
+        required: false
 extends_documentation_fragment:
 - community.vmware.vmware.documentation
 
@@ -151,8 +157,12 @@ def upgrade_tools(self, vm):
         elif vm.guest.toolsStatus == "toolsOld":
             try:
                 force = self.module.params.get('force_upgrade')
+                installer_options = self.module.params.get('installer_options')
                 if force or vm.guest.guestFamily in ["linuxGuest", "windowsGuest"]:
-                    task = vm.UpgradeTools()
+                    if installer_options is not None:
+                        task = vm.UpgradeTools(installer_options)
+                    else:
+                        task = vm.UpgradeTools()
                     changed, err_msg = wait_for_task(task)
                     result.update(changed=changed, msg=to_native(err_msg))
                 else:
@@ -182,6 +192,7 @@ def main():
         folder=dict(type='str'),
         datacenter=dict(type='str', required=True),
         force_upgrade=dict(type='bool', default=False),
+        installer_options=dict(type='str'),
     )
     module = AnsibleModule(
         argument_spec=argument_spec,


Test patch: