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

**URL:** <https://forum.ansible.com/t/vpshere-how-to-change-port-group-for-2nd-nic-on-vm-via-ansible/28636>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [September 24, 2018, 10:51am UTC](https://forum.ansible.com/t/vpshere-how-to-change-port-group-for-2nd-nic-on-vm-via-ansible/28636 "2018-09-24T10:51:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ansible\_Madness](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Ansible\_Madness](https://forum.ansible.com/u/Ansible_Madness)\
**Post date:** [September 24, 2018, 10:51am UTC](https://forum.ansible.com/t/vpshere-how-to-change-port-group-for-2nd-nic-on-vm-via-ansible/28636/1 "2018-09-24T10:51:31Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Ansible\_Madness](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Ansible\_Madness](https://forum.ansible.com/u/Ansible_Madness)\
**Post date:** [September 24, 2018, 11:10am UTC](https://forum.ansible.com/t/vpshere-how-to-change-port-group-for-2nd-nic-on-vm-via-ansible/28636/2 "2018-09-24T11:10:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jerry](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jerry/32/2572_2.png) [@Jerry](https://forum.ansible.com/u/Jerry)\
**Post date:** [April 17, 2020, 12:32pm UTC](https://forum.ansible.com/t/vpshere-how-to-change-port-group-for-2nd-nic-on-vm-via-ansible/28636/3 "2020-04-17T12:32:19Z")

</div>

Hi

Maybe this module will fix this:  
[https://docs.ansible.com/ansible/latest/modules/vmware\_guest\_network\_module.html](https://docs.ansible.com/ansible/latest/modules/vmware_guest_network_module.html)

Regards Jerry
