diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2016-08-15 09:15:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-15 09:15:01 -0400 |
commit | 4c034fd002502c56c18e9334ec969e99c39b7576 (patch) | |
tree | d5e61d3270e3b9c948bbc30d61face09e5dead5f | |
parent | 8620fda9477f7176e7a1e8d1cfbc8fdea64c8bb6 (diff) | |
download | ansible-4c034fd002502c56c18e9334ec969e99c39b7576.tar.gz |
updated container detection to new lxc (#17063)
fixes #17030
-rw-r--r-- | lib/ansible/module_utils/facts.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index b02c821ee9..0be6e7e1ab 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2877,6 +2877,7 @@ class LinuxVirtual(Virtual): # For more information, check: http://people.redhat.com/~rjones/virt-what/ def get_virtual_facts(self): + # old lxc/docker 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): @@ -2888,6 +2889,14 @@ class LinuxVirtual(Virtual): self.facts['virtualization_role'] = 'guest' return + # newer lxc does not appear in cgroups anymore but sets 'container=lxc' environment var + if os.path.exists('/proc/1/environ'): + for line in get_file_lines('/proc/1/environ'): + if re.search('container=lxc', line): + self.facts['virtualization_type'] = 'lxc' + self.facts['virtualization_role'] = 'guest' + return + if os.path.exists('/proc/vz'): self.facts['virtualization_type'] = 'openvz' if os.path.exists('/proc/bc'): |