Repository: ansible-collections/community.vmware

Issue:
vmware_vswitch sets teaming failback opposite of what's documented
<!--- 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
When using `vmware_vswitch` module to set a vSwitch teaming failback mode, the actual operation is opposite of what's [documented](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vswitch_module.html#parameters).  
`failback: no` actually sets vSwitch Failback=yes and vice versa.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
community.vmware.vmware_vswitch

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible [core 2.13.2]
  config file = /home/thomasa/esxi-build/ansible.cfg
  configured module search path = ['/home/thomasa/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/thomasa/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/thomasa/.ansible/collections:/usr/share/ansible/collections:/home/thomasa/.local/lib/python3.8/site-packages/ansible_collections
  executable location = /home/thomasa/.local/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
```

##### COLLECTION VERSION
<!--- Paste verbatim output from "ansible-galaxy collection list <namespace>.<collection>"  between the quotes
for example: ansible-galaxy collection list community.general
-->
```paste below
Collection       Version
---------------- -------
community.vmware 2.7.0  
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below
COLLECTIONS_PATHS(/home/thomasa/esxi-build/ansible.cfg) = ['/home/thomasa/.ansible/collections', '/usr/share/ansible/collections', '/home/thomasa/.lo>
DEFAULT_HOST_LIST(/home/thomasa/esxi-build/ansible.cfg) = ['/home/thomasa/esxi-build/inventory.yml']
DEFAULT_PRIVATE_KEY_FILE(/home/thomasa/esxi-build/ansible.cfg) = /home/thomasa/.ssh/id_ecdsa_ansible
DEFAULT_VAULT_PASSWORD_FILE(/home/thomasa/esxi-build/ansible.cfg) = /home/thomasa/.vault_passwd
```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
ESXi 7.0U3f  (build 20036589)

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
**Step 1 - Query current vSwitch failback setting**
```
PS C:\Users\thomasa> Get-VirtualSwitch -name vSwitch0 | Get-NicTeamingPolicy | Select-Object *
VirtualSwitchId                : key-vim.host.VirtualSwitch-vSwitch0
VirtualSwitch                  : vSwitch0
BeaconInterval                 : 1
LoadBalancingPolicy            : LoadBalanceSrcId
NetworkFailoverDetectionPolicy : LinkStatus
NotifySwitches                 : True
FailbackEnabled                : True
ActiveNic                      : {vmnic0, vmnic1}
StandbyNic                     :
UnusedNic                      :
CheckBeacon                    : False
VmHostId                       : HostSystem-ha-host
ExtensionData                  : VMware.Vim.HostNicTeamingPolicy
Uid                            : /VIServer=root@192.168.192.11:443/VMHost=HostSystem-ha-host/VirtualSwitch=key-vim.host
                                 .VirtualSwitch-vSwitch0/NicTeamingVirtualSwitchPolicy=/

```
**Step 2- Run playbook to change vSwitch failback setting**
Sample play
```
    - name: Change vSwitch0 settings
      community.vmware.vmware_vswitch:
        esxi_hostname: "{{ inventory_hostname }}"
        hostname: "{{ mgmt_ip }}"
        username: "{{ ansible_user }}"
        password: "{{ password }}"
        validate_certs: false

        switch: 'vSwitch0'
        nics: ['vmnic0','vmnic1']
        state: present
        teaming:
          failback: yes  # works reverse of how its documented
      delegate_to: localhost
```
Output
```
changed: [esxi-1 -> localhost] => {
    "changed": true,
    "failback": true,
    "invocation": {
        "module_args": {
            "esxi_hostname": "esxi-1",
            "hostname": "192.168.192.11",
            "mtu": 1500,
            "nics": [
                "vmnic0",
                "vmnic1"
            ],
            "number_of_ports": 128,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "security": null,
            "state": "present",
            "switch": "vSwitch0",
            "teaming": {
                "active_adapters": null,
                "failback": true,
                "load_balancing": null,
                "network_failure_detection": null,
                "notify_switches": null,
                "standby_adapters": null
            },
            "traffic_shaping": null,
            "username": "root",
            "validate_certs": false
        }
    },
    "notify_switches_previous": false,
    "result": "vSwitch 'vSwitch0' is updated successfully"
}
```

**Step 3 - Query vSwitch failback setting after running playbook**
```
PS C:\Users\thomasa> Get-VirtualSwitch -name vSwitch0 | Get-NicTeamingPolicy | Select-Object *
VirtualSwitchId                : key-vim.host.VirtualSwitch-vSwitch0
VirtualSwitch                  : vSwitch0
BeaconInterval                 : 1
LoadBalancingPolicy            : LoadBalanceSrcId
NetworkFailoverDetectionPolicy : LinkStatus
NotifySwitches                 : True
FailbackEnabled                : False
ActiveNic                      : {vmnic0, vmnic1}
StandbyNic                     :
UnusedNic                      :
CheckBeacon                    : False
VmHostId                       : HostSystem-ha-host
ExtensionData                  : VMware.Vim.HostNicTeamingPolicy
Uid                            : /VIServer=root@192.168.192.11:443/VMHost=HostSystem-ha-host/VirtualSwitch=key-vim.host
                                 .VirtualSwitch-vSwitch0/NicTeamingVirtualSwitchPolicy=/

```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
`failback: yes` setting should result in `FailbackEnabled: True` setting for vSwitch

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
Opposite if configured, as documented above.
`failback: yes` setting will result in `FailbackEnabled: False` setting for vSwitch
`failback: no` setting will result in `FailbackEnabled: True` setting for vSwitch


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 --->
Same issue after upgrading to `community.vmware 2.8.0` 
The module sets `rollingOrder` to `failback`:

https://github.com/ansible-collections/community.vmware/blob/65d18a66dc7ae3a707ff41080bda85347327c50c/plugins/modules/vmware_vswitch.py#L648-L654

However, according to the [documentation](https://vdc-download.vmware.com/vmwb-repository/dcr-public/bf660c0a-f060-46e8-a94d-4b5e6ffc77ad/208bc706-e281-49b6-a0ce-b402ec19ef82/SDK/vsphere-ws/docs/ReferenceGuide/vim.host.NetworkPolicy.NicTeamingPolicy.html) rollingOrder works directly opposed to how people understand failback:

> For example, assume the explicit link order is (vmnic9, vmnic0), therefore vmnic9 goes down, vmnic0 comes up. However, when vmnic9 comes backup, if rollingOrder is set to be true, vmnic0 continues to be used, otherwise, vmnic9 is restored as specified in the explicitly order.

So you get a _failback_ behavior if you set `rollingOrder` to `false`. But this should be easily fixed.

Resolving patch:
diff --git a/plugins/modules/vmware_vswitch.py b/plugins/modules/vmware_vswitch.py
--- a/plugins/modules/vmware_vswitch.py
+++ b/plugins/modules/vmware_vswitch.py
@@ -648,9 +648,10 @@ def update_teaming_policy(self, spec, results):
         # Check failback
         if teaming_failback is not None:
             results['failback'] = teaming_failback
-            if teaming_policy.rollingOrder is not teaming_failback:
-                results['notify_switches_previous'] = teaming_policy.rollingOrder
-                teaming_policy.rollingOrder = teaming_failback
+            current_failback = not teaming_policy.rollingOrder
+            if current_failback != teaming_failback:
+                results['failback_previous'] = current_failback
+                teaming_policy.rollingOrder = not teaming_failback
                 changed = True
 
         # Check teaming failover order


Test patch: