# VMWare vCenter DVS info

**URL:** <https://forum.ansible.com/t/vmware-vcenter-dvs-info/9667>\
**Category:** Get Help\
**Tags:** vmware\
**Created:** [October 4, 2024, 6:40am UTC](https://forum.ansible.com/t/vmware-vcenter-dvs-info/9667 "2024-10-04T06:40:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MK77](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MK77](https://forum.ansible.com/u/MK77)\
**Post date:** [October 4, 2024, 6:40am UTC](https://forum.ansible.com/t/vmware-vcenter-dvs-info/9667/1 "2024-10-04T06:40:29Z")

</div>

Hi,  
I am new to ansible and am trying to create a playbook to read the port groups on a DVS in vcenter. So far all I have tried is not working.  
We are running vCenter 8 so I think we need to use REST API.  
Can anyone using ansible and vcenter provide me an example of a working playbook so I can compare to mine and see where I am going wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![alainseys](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alainseys/32/2757_2.png) [@alainseys](https://forum.ansible.com/u/alainseys)\
**Post date:** [October 4, 2024, 9:31am UTC](https://forum.ansible.com/t/vmware-vcenter-dvs-info/9667/2 "2024-10-04T09:31:17Z")

</div>

This should do the trick:

```auto
 tasks:
    - name: Get DVS port groups
      community.vmware.vmware_dvs_portgroup_info:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        validate_certs: false
        dvswitch_name: "{{ dvswitch_name }}"
      register: portgroups

    - name: Print port group info
      debug:
        var: portgroups.portgroups

```

[https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware\_dvs\_portgroup\_info\_module.html](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_dvs_portgroup_info_module.html)
