def selector(module):
 if (module.params['target'] == 'host'):
  target = Host(module.params, module)
  target.site_facts()
 elif (module.params['target'] == 'hostgroup'):
  if (module.params['fullpath'] is not None):
   target = Hostgroup(module.params, module)
   target.site_facts()
  else:
   module.fail_json(msg="Parameter 'fullpath' required for target 'hostgroup'")
 else:
  module.fail_json(msg=(('Error: Unexpected target "' + module.params['target']) + '" was specified.'))

def selector ( module ) : if ( module . params [ 'target' ] == 'host' ) : target = Host ( module . params , module ) target . site_facts ( ) elif ( module . params [ 'target' ] == 'hostgroup' ) : if ( module . params [ 'fullpath' ] is not None ) : target = Hostgroup ( module . params , module ) target . site_facts ( ) else : module . fail_json ( msg = "Parameter 'fullpath' required for target 'hostgroup'" ) else : module . fail_json ( msg = ( ( 'Error: Unexpected target "' + module . params [ 'target' ] ) + '" was specified.' ) )
figure out which object and which actions to take given the right parameters .