mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
facts: correctly detect docker inside a xen host
This commit is contained in:
parent
af1f462ba0
commit
45f9800754
1 changed files with 11 additions and 11 deletions
|
@ -2582,6 +2582,17 @@ class LinuxVirtual(Virtual):
|
|||
|
||||
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
||||
def get_virtual_facts(self):
|
||||
if os.path.exists('/proc/1/cgroup'):
|
||||
for line in get_file_lines('/proc/1/cgroup'):
|
||||
if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
|
||||
self.facts['virtualization_type'] = 'docker'
|
||||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
if re.search('/lxc/', line):
|
||||
self.facts['virtualization_type'] = 'lxc'
|
||||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
|
||||
if os.path.exists("/proc/xen"):
|
||||
self.facts['virtualization_type'] = 'xen'
|
||||
self.facts['virtualization_role'] = 'guest'
|
||||
|
@ -2607,17 +2618,6 @@ class LinuxVirtual(Virtual):
|
|||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
|
||||
if os.path.exists('/proc/1/cgroup'):
|
||||
for line in get_file_lines('/proc/1/cgroup'):
|
||||
if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
|
||||
self.facts['virtualization_type'] = 'docker'
|
||||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
if re.search('/lxc/', line):
|
||||
self.facts['virtualization_type'] = 'lxc'
|
||||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
|
||||
product_name = get_file_content('/sys/devices/virtual/dmi/id/product_name')
|
||||
|
||||
if product_name in ['KVM', 'Bochs']:
|
||||
|
|
Loading…
Reference in a new issue