How to find Virtual or Physical?

367 views
Skip to first unread message

Somasundaram R

unread,
Aug 24, 2021, 6:00:34 AM8/24/21
to Ansible Project
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


Roberto Paz

unread,
Aug 24, 2021, 11:38:12 AM8/24/21
to Ansible Project
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.

Jorge Rúa

unread,
Aug 24, 2021, 12:03:35 PM8/24/21
to ansible...@googlegroups.com
Have a look to virt-what 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/26757f0a-a270-4db0-b98d-fabda0a4451cn%40googlegroups.com.

Oskar Almlöv

unread,
Aug 24, 2021, 12:14:27 PM8/24/21
to ansible...@googlegroups.com, Jorge Rúa

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

Oskar.

Somasundaram R

unread,
Aug 24, 2021, 10:53:57 PM8/24/21
to Ansible Project
Hi, My scenario is also same. Thanks. 

Somasundaram R

unread,
Aug 24, 2021, 10:55:40 PM8/24/21
to Ansible Project
Thank you all.
Reply all
Reply to author
Forward
0 new messages