diff --git a/changelogs/fragments/dev-kvm.yml b/changelogs/fragments/dev-kvm.yml new file mode 100644 index 00000000000..d18b1e4101a --- /dev/null +++ b/changelogs/fragments/dev-kvm.yml @@ -0,0 +1,2 @@ +minor_changes: + - facts - ``/dev/kvm`` is now consulted in Linux virtualization facts, and the host is considered a KVM host if this file exists and none of the pre-existing checks matched. diff --git a/lib/ansible/module_utils/facts/virtual/linux.py b/lib/ansible/module_utils/facts/virtual/linux.py index e133df42958..db591402871 100644 --- a/lib/ansible/module_utils/facts/virtual/linux.py +++ b/lib/ansible/module_utils/facts/virtual/linux.py @@ -238,6 +238,11 @@ class LinuxVirtual(Virtual): virtual_facts['virtualization_role'] = 'guest' return virtual_facts + if os.path.exists('/dev/kvm'): + virtual_facts['virtualization_type'] = 'kvm' + virtual_facts['virtualization_role'] = 'host' + return virtual_facts + # If none of the above matches, return 'NA' for virtualization_type # and virtualization_role. This allows for proper grouping. virtual_facts['virtualization_type'] = 'NA'