#NEWLINE# def main( ) : #NEWLINE# #INDENT# argument_spec = dict ( match_mode = dict ( required = False , choices = [ 'strict' , 'prefix' ] , default = 'strict' ) , name = dict ( aliases = [ 'partition_name' ] , required = True , type = 'str' ) ) #NEWLINE# module = AnsibleModule ( argument_spec ) #NEWLINE# match_mode = module . params . get ( 'match_mode' ) #NEWLINE# name = module . params . get ( 'name' ) #NEWLINE# try : #NEWLINE# #INDENT# ret = list ( ) #NEWLINE# ct = pyudev . Context ( ) #NEWLINE# for dev in find_disk ( ct , name , match_mode ) : #NEWLINE# #INDENT# for info in extract_disk_info ( ct , dev , name ) : #NEWLINE# #INDENT# if info : #NEWLINE# #INDENT# ret . append ( info ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# module . exit_json ( disks = json . dumps ( ret ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# module . exit_json ( failed = True , msg = repr ( e ) )