|
|
@ -8,7 +8,7 @@ import os
|
|
|
|
from ansible.module_utils.facts.collector import BaseFactCollector
|
|
|
|
from ansible.module_utils.facts.collector import BaseFactCollector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_chroot():
|
|
|
|
def is_chroot(module=None):
|
|
|
|
|
|
|
|
|
|
|
|
is_chroot = None
|
|
|
|
is_chroot = None
|
|
|
|
|
|
|
|
|
|
|
@ -22,7 +22,17 @@ def is_chroot():
|
|
|
|
is_chroot = my_root.st_ino != proc_root.st_ino or my_root.st_dev != proc_root.st_dev
|
|
|
|
is_chroot = my_root.st_ino != proc_root.st_ino or my_root.st_dev != proc_root.st_dev
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
# I'm not root or no proc, fallback to checking it is inode #2
|
|
|
|
# I'm not root or no proc, fallback to checking it is inode #2
|
|
|
|
is_chroot = (my_root.st_ino != 2)
|
|
|
|
fs_root_ino = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if module is not None:
|
|
|
|
|
|
|
|
stat_path = module.get_bin_path('stat')
|
|
|
|
|
|
|
|
if stat_path:
|
|
|
|
|
|
|
|
cmd = [stat_path, '-f', '--format=%T', '/']
|
|
|
|
|
|
|
|
rc, out, err = module.run_command(cmd)
|
|
|
|
|
|
|
|
if 'btrfs' in out:
|
|
|
|
|
|
|
|
fs_root_ino = 256
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_chroot = (my_root.st_ino != fs_root_ino)
|
|
|
|
|
|
|
|
|
|
|
|
return is_chroot
|
|
|
|
return is_chroot
|
|
|
|
|
|
|
|
|
|
|
@ -32,4 +42,4 @@ class ChrootFactCollector(BaseFactCollector):
|
|
|
|
_fact_ids = set(['is_chroot'])
|
|
|
|
_fact_ids = set(['is_chroot'])
|
|
|
|
|
|
|
|
|
|
|
|
def collect(self, module=None, collected_facts=None):
|
|
|
|
def collect(self, module=None, collected_facts=None):
|
|
|
|
return {'is_chroot': is_chroot()}
|
|
|
|
return {'is_chroot': is_chroot(module)}
|
|
|
|