Skip to content

Instantly share code, notes, and snippets.

Created October 1, 2012 11:40
Show Gist options
  • Save anonymous/3811126 to your computer and use it in GitHub Desktop.
Save anonymous/3811126 to your computer and use it in GitHub Desktop.
.ssh/config for ansible
bluszcz@rafal-dagens ~/repo/ansible $ git diff
diff --git a/lib/ansible/runner/connection_plugins/paramiko_ssh.py b/lib/ansible/runner/connection_plugins/paramiko_ssh.py
index b0f8c51..e9b0f2d 100644
--- a/lib/ansible/runner/connection_plugins/paramiko_ssh.py
+++ b/lib/ansible/runner/connection_plugins/paramiko_ssh.py
@@ -29,6 +29,7 @@ with warnings.catch_warnings():
warnings.simplefilter("ignore")
try:
import paramiko
+ from paramiko import SSHClient, SSHConfig
HAVE_PARAMIKO=True
except ImportError:
pass
@@ -55,6 +56,27 @@ class Connection(object):
vvv("ESTABLISH CONNECTION FOR USER: %s" % user, host=self.host)
+
+
+ ### BLUSZCZ MESS
+ config = SSHConfig()
+ home_directory = os.getenv('HOME')
+ config.parse(open(os.path.join(home_directory, '.ssh/config')))
+ o = config.lookup(self.host)
+ #print o
+
+
+ if o.has_key('port'):
+ self.port = int(o['port'])
+ if o.has_key('hostname'):
+ self.host = o['hostname']
+ if o.has_key('user'):
+ user = o['user']
+
+
+
+ #print "HOST",self.host, self.port, user
+
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment