Distinguous b/w VMs and some are bare metal servers by using the ansible

In ansible playbook, i need to run one playbook on different servers, some are VMs and some are bare metal servers, i couldn’t find a good way to distinguish VM rather than the other, any idea in this regard?

What difference to your ansible does it make if a host is a VM or a bare metal machine?

look for values for a virtual , virtualization_role , virtualization_type hardware in ansible_facts . You may collect using ansible setup .

@al1 , Well, there could be many :slight_smile: , Below are some I could think of ,

  • If the o/s is linux , a tuned profile specific to virtual machines ( eg: virtual-guest)
  • Different I/O scheduling policy on guest such noop or deadline vs cfq on baremetal
  • An update or installation of guest-agent etc.
  • Kernel config parameters such as huge-pages .

I want to set different tags while installing the antivirus