Fabric takes a lot of time using ssh

I run the fabric to automate the deployment. It is very slow.

My local environment:

(somenv) bob@sh ~/code/somenv/somenv/fabfile $ > uname -a Darwin sh.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 

My fab file:

 #!/usr/bin/env python import logging import paramiko as ssh from fabric.api import env, run env.hosts = [ 'examplesite'] env.use_ssh_config = True #env.forward_agent = True logging.basicConfig(level=logging.INFO) ssh.util.log_to_file('/tmp/paramiko.log') def uptime(): run('uptime') 

Here are some debug logs:

 (somenv) bob@sh ~/code/somenv/somenv/fabfile $ > date;fab -f /Users/bob/code/somenv/somenv/fabfile/pefabfile.py uptime Sun Aug 11 22:25:03 EDT 2013 [examplesite] Executing task 'uptime' [examplesite] run: uptime DEB [20130811-22:25:23.610] thr=1 paramiko.transport: starting thread (client mode): 0x13e4650L INF [20130811-22:25:23.630] thr=1 paramiko.transport: Connected (version 2.0, client OpenSSH_5.9p1) DEB [20130811-22:25:23.641] thr=1 paramiko.transport: kex algos:['ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-grou 

It takes 20 seconds before paramiko even starts the flow. Of course, the Executing task 'uptime' not so long. I can manually log in via ssh, enter uptime and exit after 5-6 seconds. I would appreciate help in extracting mode debugging information. I made the changes mentioned here , but it makes no difference.

+4
source share
3 answers

This may be a problem with DNS and / or IPv6 resolution.

A few things you can try:

  • replace the server name by its IP address in env.hosts
  • disabling IPv6
  • use a different DNS server (e.g. OpenDNS)
0
source

For those watching this 2014 post, paramiko , which was a slow component when checking for known hosts, introduced a patch in March 2014 (v1.13) that was resolved as a Fabric requirement in v1. 9.0 and vice versa in v1.8.4 and v1.7.4.

So, upgrade!

0
source

Source: https://habr.com/ru/post/1496480/


All Articles