From a0c34da779f583915a945f4ec039dd5f7b6e422c Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Wed, 8 Apr 2015 13:57:56 -0400 Subject: [PATCH] Support querying systemd container information systemd writes a /run/systemd/container file in any container it starts to make it really easy to detect the container type. This adds support for detecting systemd-nspawn containers (and any other container format that will write data there for compatibility). --- lib/ansible/module_utils/facts.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 628d1dd267..300ed3ad2e 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2394,6 +2394,12 @@ class LinuxVirtual(Virtual): self.facts['virtualization_role'] = 'guest' return + systemd_container = get_file_content('/run/systemd/container') + if systemd_container: + self.facts['virtualization_type'] = systemd_container + 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):