mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-29 08:01:24 -07:00
parent
8620fda947
commit
4c034fd002
1 changed files with 9 additions and 0 deletions
|
@ -2877,6 +2877,7 @@ class LinuxVirtual(Virtual):
|
||||||
|
|
||||||
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
||||||
def get_virtual_facts(self):
|
def get_virtual_facts(self):
|
||||||
|
# old lxc/docker
|
||||||
if os.path.exists('/proc/1/cgroup'):
|
if os.path.exists('/proc/1/cgroup'):
|
||||||
for line in get_file_lines('/proc/1/cgroup'):
|
for line in get_file_lines('/proc/1/cgroup'):
|
||||||
if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
|
if re.search(r'/docker(/|-[0-9a-f]+\.scope)', line):
|
||||||
|
@ -2888,6 +2889,14 @@ class LinuxVirtual(Virtual):
|
||||||
self.facts['virtualization_role'] = 'guest'
|
self.facts['virtualization_role'] = 'guest'
|
||||||
return
|
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'):
|
if os.path.exists('/proc/vz'):
|
||||||
self.facts['virtualization_type'] = 'openvz'
|
self.facts['virtualization_type'] = 'openvz'
|
||||||
if os.path.exists('/proc/bc'):
|
if os.path.exists('/proc/bc'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue