Repository: ansible-collections/community.vmware

Issue:
vmware_guest: remove hardware version number check to avoid updating the restriction everytime
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
<!--- Explain the problem briefly below -->
Can we remove the hardware version number check in vmware_guest module? or find another better way to do this? or we need to change this restriction every time after vSphere new releases and new hardware version introduced.


##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
vmware_guest

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below

```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->


##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
try:
                    temp_version = int(temp_version)
                except ValueError:
                    hw_version_check_failed = True

                if temp_version not in range(3, 18):
                    hw_version_check_failed = True

                if hw_version_check_failed:
                    self.module.fail_json(msg="Failed to set hardware.version '%s' value as valid"
                                          " values range from 3 (ESX 2.x) to 17 (ESXi 7.0)." % temp_version)
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
We do not need to change this `range(3, 18)` every time when there is new hardware version introduced in new vSphere release, e.g., hardware version 18, 19, etc.

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```paste below

```



Discussion:
Files identified in the description:
* [`plugins/modules/vmware_guest.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_guest.py)

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 --->
cc @Akasurde @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I agree, this check doesn't make much sense. Even if the version is theoretically valid, it doesn't mean the module will work. Like using version 18 but the vCenter or ESXi is 6.5. I think we should just remove this check.

I'll do a PR and request your review.

Resolving patch:
diff --git a/plugins/modules/vmware_guest.py b/plugins/modules/vmware_guest.py
--- a/plugins/modules/vmware_guest.py
+++ b/plugins/modules/vmware_guest.py
@@ -1741,7 +1741,6 @@ def configure_hardware_params(self, vm_obj):
 
         temp_version = self.params['hardware']['version']
         if temp_version is not None:
-            hw_version_check_failed = False
             if temp_version.lower() == 'latest':
                 # Check is to make sure vm_obj is not of type template
                 if vm_obj and not vm_obj.config.template:
@@ -1757,14 +1756,10 @@ def configure_hardware_params(self, vm_obj):
                 try:
                     temp_version = int(temp_version)
                 except ValueError:
-                    hw_version_check_failed = True
-
-                if temp_version not in range(3, 18):
-                    hw_version_check_failed = True
-
-                if hw_version_check_failed:
                     self.module.fail_json(msg="Failed to set hardware.version '%s' value as valid"
-                                          " values range from 3 (ESX 2.x) to 17 (ESXi 7.0)." % temp_version)
+                                          " values are either 'latest' or a number."
+                                          " Please check VMware documentation for valid VM hardware versions." % temp_version)
+
                 # Hardware version is denoted as "vmx-10"
                 version = "vmx-%02d" % temp_version
                 self.configspec.version = version


Test patch: