@ -41,7 +41,6 @@ options:
name :
name :
description :
description :
- Name of the VM to work with
- Name of the VM to work with
required : True
name_match :
name_match :
description :
description :
- If multiple VMs matching the name , use the first or last found
- If multiple VMs matching the name , use the first or last found
@ -168,13 +167,14 @@ def main():
default = os . environ . get ( ' VMWARE_PASSWORD ' )
default = os . environ . get ( ' VMWARE_PASSWORD ' )
) ,
) ,
validate_certs = dict ( required = False , type = ' bool ' , default = True ) ,
validate_certs = dict ( required = False , type = ' bool ' , default = True ) ,
name = dict ( required = Tru e, type = ' str ' ) ,
name = dict ( required = Fals e, type = ' str ' ) ,
name_match = dict ( required = False , type = ' str ' , default = ' first ' ) ,
name_match = dict ( required = False , type = ' str ' , default = ' first ' ) ,
uuid = dict ( required = False , type = ' str ' ) ,
uuid = dict ( required = False , type = ' str ' ) ,
folder = dict ( required = False , type = ' str ' , default = ' /vm ' ) ,
folder = dict ( required = False , type = ' str ' , default = ' /vm ' ) ,
datacenter = dict ( required = True , type = ' str ' ) ,
datacenter = dict ( required = True , type = ' str ' ) ,
) ,
) ,
required_together = [ ( ' name ' , ' folder ' ) ] ,
required_together = [ ( ' name ' , ' folder ' ) ] ,
required_one_of = [ [ ' name ' , ' uuid ' ] ] ,
)
)
# FindByInventoryPath() does not require an absolute path
# FindByInventoryPath() does not require an absolute path
@ -194,7 +194,12 @@ def main():
except Exception as exc :
except Exception as exc :
module . fail_json ( msg = " Fact gather failed with exception %s " % to_text ( exc ) )
module . fail_json ( msg = " Fact gather failed with exception %s " % to_text ( exc ) )
else :
else :
module . fail_json ( msg = " Unable to gather facts for non-existing VM %(name)s " % module . params )
msg = " Unable to gather facts for non-existing VM "
if module . params [ ' name ' ] :
msg + = " %(name)s " % module . params
elif module . params [ ' uuid ' ] :
msg + = " %(uuid)s " % module . params
module . fail_json ( msg = msg )
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :
main ( )
main ( )