How to find Virtual or Physical?

Hi everyone,

Please help me to find host is virtual or physical from ansible facts.Thanks.
Is it possible to get the details from “ansible_virtualization_type”. Or is there any better idea.
Thanks in advance

I required to do that ìn the past and the best way I found was to access the kernel information:

shell: ‘dmesg | grep “Hypervisor detected”’

I had to identify VMWare-based VMs or Physical server at that time.

Have a look to virt-what

Another Idea could be to include a local fact in the image that you base your virtual machines on. Or put it there in an earlier stage after the machine has been provisioned.
See this link: https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#adding-custom-facts

Hi, My scenario is also same. Thanks.

Thank you all.