# Assign different variables to each server from vmware dynamic inventory

**URL:** <https://forum.ansible.com/t/assign-different-variables-to-each-server-from-vmware-dynamic-inventory/36243>\
**Category:** Ansible Project\
**Tags:** windows, vmware, rhel\
**Created:** [January 23, 2022, 7:13pm UTC](https://forum.ansible.com/t/assign-different-variables-to-each-server-from-vmware-dynamic-inventory/36243 "2022-01-23T19:13:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amjad\_Saleem1](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Amjad\_Saleem1](https://forum.ansible.com/u/Amjad_Saleem1)\
**Post date:** [January 23, 2022, 7:13pm UTC](https://forum.ansible.com/t/assign-different-variables-to-each-server-from-vmware-dynamic-inventory/36243/1 "2022-01-23T19:13:10Z")

</div>

I am getting vms from vcenter using vmware inventory plugin. The vms are mix of windows and linux. I want to assign ansible\_connection: ssh if the vm is linux and ansible\_connection: winrm if windows. Using compose as below assign ansible\_connection: ssh to all vms irresptive if they are linux or windows:

plugin: community.vmware.vmware\_vm\_inventory strict: False hostname: 10.65.223.31 username: administrator@vsphere.local password: xxxxxx validate\_certs: False

filters: - guest.guestId is match(‘rhel\*’) or guest.guestId is match(‘windows\*’) compose: ansible\_host: ‘guest.ipAddress’ composed\_var: ‘config.name’ # This will populate a host variable with a string value ansible\_user: “‘admin’” ansible\_connection: “‘ssh’” groups: VMs: True hostnames: - config.name

How do I assign different vars based on OS or group names?
