Skip to content

Commit

Permalink
facts: correctly detect docker inside a xen host
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU committed Sep 30, 2015
1 parent af1f462 commit 45f9800
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/ansible/module_utils/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,17 @@ def populate(self):

# 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'
Expand All @@ -2607,17 +2618,6 @@ def get_virtual_facts(self):
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']:
Expand Down

0 comments on commit 45f9800

Please sign in to comment.