mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Check presence of files under /proc before opening them
This commit is contained in:
parent
8b27085c34
commit
5e68143c46
1 changed files with 25 additions and 23 deletions
|
@ -967,6 +967,7 @@ class LinuxVirtual(Virtual):
|
|||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
|
||||
if os.path.exists('/proc/self/status'):
|
||||
for line in open('/proc/self/status').readlines():
|
||||
if re.match('^VxID: \d+', line):
|
||||
self.facts['virtualization_type'] = 'linux_vserver'
|
||||
|
@ -976,6 +977,7 @@ class LinuxVirtual(Virtual):
|
|||
self.facts['virtualization_role'] = 'guest'
|
||||
return
|
||||
|
||||
if os.path.exists('/proc/cpuinfo'):
|
||||
for line in open('/proc/cpuinfo').readlines():
|
||||
if re.match('^model name.*QEMU Virtual CPU', line):
|
||||
self.facts['virtualization_type'] = 'kvm'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue