mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Detect docker as virtualization_type
New docker versions use "docker" in /proc/1/cgroup, which disturbs the virtualization_type detection. So, grep for docker, in addition of "lxc".
This commit is contained in:
@@ -2159,6 +2159,10 @@ class LinuxVirtual(Virtual):
|
||||
|
||||
if os.path.exists('/proc/1/cgroup'):
|
||||
for line in open('/proc/1/cgroup').readlines():
|
||||
if re.search('/docker/', 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'
|
||||
|
||||
Reference in New Issue
Block a user