def add_git_host_key(module, url, accept_hostkey=True, create_dir=True):
 if is_ssh_url(url):
  fqdn = get_fqdn(url)
  if fqdn:
   known_host = check_hostkey(module, fqdn)
   if (not known_host):
    if accept_hostkey:
     (rc, out, err) = add_host_key(module, fqdn, create_dir=create_dir)
     if (rc != 0):
      module.fail_json(msg=('failed to add %s hostkey: %s' % (fqdn, (out + err))))
    else:
     module.fail_json(msg=('%s has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module' % fqdn))

def add_git_host_key ( module , url , accept_hostkey = True , create_dir = True ) : if is_ssh_url ( url ) : fqdn = get_fqdn ( url ) if fqdn : known_host = check_hostkey ( module , fqdn ) if ( not known_host ) : if accept_hostkey : ( rc , out , err ) = add_host_key ( module , fqdn , create_dir = create_dir ) if ( rc != 0 ) : module . fail_json ( msg = ( 'failed to add %s hostkey: %s' % ( fqdn , ( out + err ) ) ) ) else : module . fail_json ( msg = ( '%s has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module' % fqdn ) )
idempotently add a git url hostkey .