Repository: ansible-collections/community.vmware

Issue:
When using vmware_vswitch, allow removing NICs
<!--- 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 -->
Same request as described[ here.]( https://github.com/ansible/ansible/issues/44589)

Request looks to have been closed due to repo move, but still would be nice to have.
(copying steps to reproduce from linked issue that was closed):

```
- name: Add host to a standard vSwitch
  delegate_to: localhost
  vmware_vswitch:
    hostname: '{{ ansible_nodename }}'
    mtu: '{{ vswitch.mtu }}'
    nics: '{{ vswitch.vmnics }}'
    password: '{{ esx_password }}'
    state: '{{ vswitch.state }}'
    switch: '{{ vswitch.name }}'
    username: '{{ esx_user }}'
    validate_certs: '{{ validate_certs }}'


```
1. Run the above where vswitch.vmnics is this:
```
 vswitch:
   vmnics:
     - vmnic0
     - vmnic1
     - vmnic2
```
2. Run it again, but remove one of the nics to look like this:

```
 vswitch:
   vmnics:
     - vmnic0
     - vmnic2
```

You'll see success / no change.

EXPECTED RESULTS

I'd expect vmnic1 to be removed from the switch.

ACTUAL RESULTS
Nothing changes. This is because the vmware_vswitch module only adds NICs that aren't already on the switch. It doesn't remove a NIC from the switch.

##### ISSUE TYPE
- Feature Idea

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
vmware_vswitch

##### ADDITIONAL INFORMATION
<!--- Describe how the feature would be used, why it is needed and what it would solve -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml

```

<!--- HINT: You can also paste gist.github.com links for larger files -->



Discussion:
Files identified in the description:
* [`plugins/modules/vmware_vswitch.py`](https://github.com/['ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_vswitch.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 @goneri @lparkes @pgbidkar @warthog9
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Files identified in the description:
* [`plugins/modules/vmware_vswitch.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_vswitch.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 --->
Hello,
I confirm this issue with this env :
- ansible 2.9.20
- python version = 3.6.9
- community.vmware 1.9 (release)

It's would be a nice feature because there is no warning about this comportement !
Hello, i confirm it could be useful

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
@@ -292,17 +292,24 @@ def state_update_vswitch(self):
         """
         results = dict(changed=False, result="No change in vSwitch '%s'" % self.switch)
         vswitch_pnic_info = self.available_vswitches[self.switch]
-        remain_pnic = []
+        pnic_add = []
         for desired_pnic in self.nics:
             if desired_pnic not in vswitch_pnic_info['pnic']:
-                remain_pnic.append(desired_pnic)
-
+                pnic_add.append(desired_pnic)
+        pnic_remove = []
+        for configured_pnic in vswitch_pnic_info['pnic']:
+            if configured_pnic not in self.nics:
+                pnic_remove.append(configured_pnic)
         diff = False
         # Update all nics
         all_nics = vswitch_pnic_info['pnic']
-        if remain_pnic:
-            all_nics += remain_pnic
+        if pnic_add or pnic_remove:
             diff = True
+            if pnic_add:
+                all_nics += pnic_add
+            if pnic_remove:
+                for pnic in pnic_remove:
+                    all_nics.remove(pnic)
 
         if vswitch_pnic_info['mtu'] != self.mtu or \
                 vswitch_pnic_info['num_ports'] != self.number_of_ports:


Test patch: