From 45f98007540ac9ac1694a8505e2ad763bf135d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 30 Sep 2015 17:08:21 +0200 Subject: [PATCH] facts: correctly detect docker inside a xen host --- lib/ansible/module_utils/facts.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 0143d0fcfc..c8b2056f10 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -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']: