From 056a0203577c3f32302b989be6cb4f1d8978ebbf Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sat, 26 Sep 2015 09:54:56 -0700 Subject: [PATCH] Do not fail if /proc/uptime is not present This can happen in chroot environments that don't have all of /proc available --- lib/ansible/module_utils/facts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 609e13ac597..0143d0fcfc4 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1089,8 +1089,10 @@ class LinuxHardware(Hardware): self.facts['devices'][diskname] = d def get_uptime_facts(self): - uptime_seconds_string = get_file_content('/proc/uptime').split(' ')[0] - self.facts['uptime_seconds'] = int(float(uptime_seconds_string)) + uptime_file_content = get_file_content('/proc/uptime') + if uptime_file_content: + uptime_seconds_string = uptime_file_content.split(' ')[0] + self.facts['uptime_seconds'] = int(float(uptime_seconds_string)) def get_lvm_facts(self): """ Get LVM Facts if running as root and lvm utils are available """