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?