@ -228,12 +228,15 @@ class Hardware(FactsBase):
data = self . responses [ 1 ]
data = self . responses [ 1 ]
if data :
if data :
processor_line = [ l for l in data . splitlines ( )
if ' Invalid input detected ' in data :
if ' Processor ' in l ] . pop ( )
warnings . append ( ' Unable to gather memory statistics ' )
match = re . findall ( r ' \ s( \ d+) \ s ' , processor_line )
else :
if match :
processor_line = [ l for l in data . splitlines ( )
self . facts [ ' memtotal_mb ' ] = int ( match [ 0 ] ) / 1024
if ' Processor ' in l ] . pop ( )
self . facts [ ' memfree_mb ' ] = int ( match [ 3 ] ) / 1024
match = re . findall ( r ' \ s( \ d+) \ s ' , processor_line )
if match :
self . facts [ ' memtotal_mb ' ] = int ( match [ 0 ] ) / 1024
self . facts [ ' memfree_mb ' ] = int ( match [ 3 ] ) / 1024
def parse_filesystems ( self , data ) :
def parse_filesystems ( self , data ) :
return re . findall ( r ' ^Directory of ( \ S+)/ ' , data , re . M )
return re . findall ( r ' ^Directory of ( \ S+)/ ' , data , re . M )
@ -446,6 +449,9 @@ FACT_SUBSETS = dict(
VALID_SUBSETS = frozenset ( FACT_SUBSETS . keys ( ) )
VALID_SUBSETS = frozenset ( FACT_SUBSETS . keys ( ) )
global warnings
warnings = list ( )
def main ( ) :
def main ( ) :
""" main entry point for module execution
""" main entry point for module execution
@ -508,7 +514,6 @@ def main():
key = ' ansible_net_ %s ' % key
key = ' ansible_net_ %s ' % key
ansible_facts [ key ] = value
ansible_facts [ key ] = value
warnings = list ( )
check_args ( module , warnings )
check_args ( module , warnings )
module . exit_json ( ansible_facts = ansible_facts , warnings = warnings )
module . exit_json ( ansible_facts = ansible_facts , warnings = warnings )