# How to find Virtual or Physical?

**URL:** <https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665>\
**Category:** Ansible Project\
**Created:** [August 24, 2021, 10:00am UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665 "2021-08-24T10:00:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somasundaram\_R](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Somasundaram\_R](https://forum.ansible.com/u/Somasundaram_R)\
**Post date:** [August 24, 2021, 10:00am UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/1 "2021-08-24T10:00:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Roberto\_J\_R\_Paz](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Roberto\_J\_R\_Paz](https://forum.ansible.com/u/Roberto_J_R_Paz)\
**Post date:** [August 24, 2021, 3:38pm UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/2 "2021-08-24T15:38:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jorge\_Rua1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jorge\_Rua1](https://forum.ansible.com/u/Jorge_Rua1)\
**Post date:** [August 24, 2021, 4:03pm UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/3 "2021-08-24T16:03:04Z")

</div>

Have a look to virt-what

---

<div class="post-metadata">

**Author:** ![Oskar\_Almlov](https://avatars.discourse-cdn.com/v4/letter/o/34f0e0/32.png) [@Oskar\_Almlov](https://forum.ansible.com/u/Oskar_Almlov)\
**Post date:** [August 24, 2021, 4:14pm UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/4 "2021-08-24T16:14:12Z")

</div>

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](https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#adding-custom-facts)

---

<div class="post-metadata">

**Author:** ![Somasundaram\_R](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Somasundaram\_R](https://forum.ansible.com/u/Somasundaram_R)\
**Post date:** [August 25, 2021, 2:53am UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/5 "2021-08-25T02:53:57Z")

</div>

Hi, My scenario is also same. Thanks.

---

<div class="post-metadata">

**Author:** ![Somasundaram\_R](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Somasundaram\_R](https://forum.ansible.com/u/Somasundaram_R)\
**Post date:** [August 25, 2021, 2:55am UTC](https://forum.ansible.com/t/how-to-find-virtual-or-physical/35665/6 "2021-08-25T02:55:39Z")

</div>

Thank you all.
