Repository: ansible-collections/community.vmware

Issue:
vmware_cluster_info does not provide correct data for enabled_vsan
<!--- 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 -->
The data returned from vmware_cluster_info includes a property named "enabled_vsan" but it is not accurate and instead appears to always return false, even when vSAN is enabled in a cluster

##### 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_cluster_info

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.9.16
  config file = /home/username/AWX/ansible.cfg
  configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below
ANSIBLE_SSH_ARGS(/home/username/AWX/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
COLLECTIONS_PATHS(/home/username/AWX/ansible.cfg) = ['/home/username/AWX/collections']
DEFAULT_FILTER_PLUGIN_PATH(/home/username/AWX/ansible.cfg) = ['/home/username/AWX/custom_filters']
DEFAULT_ROLES_PATH(/home/username/AWX/ansible.cfg) = ['/home/username/AWX/roles']
```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
vCenter 6.7 U3
ESXi Hosts 6.7 U3

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
Run playbook below and debug the registered output.  All clusters show "enabled_vsan: false" even on clusters that are known for having vSAN enabled and in use.

<!--- Paste example playbooks or commands between quotes below -->
```yaml
    - name: Gather cluster information from Datacenters
      vmware_cluster_info:
        hostname: "{{ source_vcenter }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_password }}"
        datacenter: "{{ datacenter_name }}"
        validate_certs: "{{ validate_certs }}"
      delegate_to: localhost
      register: cluster_info
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
enabled_vsan property accurately reflect true when vSAN is enabled on a cluster

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```paste below
TASK [Gather cluster information from Datacenters] **************************************************************************************************************************************************
task path: /home/username/AWX/VMware/cluster_configuration.yml:78
Trying secret FileVaultSecret(filename='/home/username/vault.txt') for vault_id=default
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: username
<localhost> EXEC /bin/sh -c 'echo ~username && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/username/.ansible/tmp `"&& mkdir "` echo /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732 `" && echo ansible-tmp-1613688264.6778567-2298045-177199244433732="` echo /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732 `" ) && sleep 0'
Using module file /home/username/AWX/collections/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py
<localhost> PUT /home/username/.ansible/tmp/ansible-local-2298009jfqcszdk/tmp4jhv7ihk TO /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732/AnsiballZ_vmware_cluster_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732/ /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732/AnsiballZ_vmware_cluster_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/libexec/platform-python /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732/AnsiballZ_vmware_cluster_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/username/.ansible/tmp/ansible-tmp-1613688264.6778567-2298045-177199244433732/ > /dev/null 2>&1 && sleep 0'
ok: [datacenter_LabDC] => {
    "changed": false,
    "clusters": {
        "Lab01": {
            "datacenter": "LabDC",
            "drs_default_vm_behavior": "fullyAutomated",
            "drs_enable_vm_behavior_overrides": true,
            "drs_vmotion_rate": 3,
            "enable_ha": true,
            "enabled_drs": true,
            "enabled_vsan": false,
            "ha_admission_control_enabled": true,
            "ha_failover_level": 1,
            "ha_host_monitoring": "enabled",
            "ha_restart_priority": [
                "medium"
            ],
            "ha_vm_failure_interval": [
                30
            ],
            "ha_vm_max_failure_window": [
                -1
            ],
            "ha_vm_max_failures": [
                3
            ],
            "ha_vm_min_up_time": [
                120
            ],
            "ha_vm_monitoring": "vmMonitoringDisabled",
            "ha_vm_tools_monitoring": [
                "vmMonitoringDisabled"
            ],```



Discussion:
Files identified in the description:
* [`plugins/modules/vmware_cluster_info.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_cluster_info.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 @Tomorrow9 @digifuchsi @goneri @lparkes @pgbidkar @warthog9
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I think this:

https://github.com/ansible-collections/community.vmware/blob/f6ed64f139addcabde07786b91478f3cacfcf258/plugins/modules/vmware_cluster_info.py#L283-L284

should use [vsanConfigInfo](https://vdc-download.vmware.com/vmwb-repository/dcr-public/b50dcbbf-051d-4204-a3e7-e1b618c1e384/538cf2ec-b34f-4bae-a332-3820ef9e7773/vim.cluster.ConfigInfoEx.html#field_detail) instead of just vsanConfig.

Resolving patch:
diff --git a/plugins/modules/vmware_cluster_info.py b/plugins/modules/vmware_cluster_info.py
--- a/plugins/modules/vmware_cluster_info.py
+++ b/plugins/modules/vmware_cluster_info.py
@@ -280,8 +280,8 @@ def gather_cluster_info(self):
                 drs_config = cluster.configurationEx.drsConfig
 
                 # VSAN
-                if hasattr(cluster.configurationEx, 'vsanConfig'):
-                    vsan_config = cluster.configurationEx.vsanConfig
+                if hasattr(cluster.configurationEx, 'vsanConfigInfo'):
+                    vsan_config = cluster.configurationEx.vsanConfigInfo
                     enabled_vsan = vsan_config.enabled,
                     vsan_auto_claim_storage = vsan_config.defaultConfig.autoClaimStorage,
 


Test patch: