vpshere: how to change port group for 2nd NIC on VM via ansible

Scenario: VM on ESXi with 2 NICS
Network_adapter1: Fixed port group/VLAN
Network_adapter2: Variable port group/VLAN

So all i am trying to achieve with ansible is to modify the port group/VLAN of Network_adapter2, is this even possible?

I looked at https://docs.ansible.com/ansible/latest/modules/vmware_guest_module.html#vmware-guest-module (networks section), but don’t really think this will achieve what i require

In vsphere this can be achieve din the powershell with something like ‘set-networkadapter -Portgroup “XXX”’ for the interface in question

Many thanks for anyone with experience here.

Cheers
Rod

So seems the vmware_guest module is in fact ok - however there appears to be no way to specify the NIC but have to rely on the order of the list and perform the port group change to each Adapter

example:

  • vmware_guest:
    .
    .
    networks:
  • name: management
  • name: changeme

Good enough for my needs

Cheers

Hi

Maybe this module will fix this:
https://docs.ansible.com/ansible/latest/modules/vmware_guest_network_module.html

Regards Jerry