Created
August 9, 2013 20:21
-
-
Save jimi-c/6196856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SSHConnection(...) | |
| """ initiates an ssh connection """ | |
| ... | |
| class Connection(SSHConnection): | |
| def __init__(self, runner, host, port, user, password, private_key_file, *args, **kwargs): | |
| super(Connection,self).__init__( | |
| runner=runner, | |
| host=host, | |
| port=port, | |
| user=user, | |
| password=password, | |
| private_key_file=private_key_file | |
| ) | |
| self.host = host | |
| self.context = None | |
| self.conn = None | |
| self.key = utils.key_for_hostname(host) | |
| self.fbport = 50994 | |
| def _execute_fb_module(self, conn): | |
| args = "password=%s port=%s" % (self.key,str(self.fbport)) | |
| return self.runner._execute_module(conn, "/tmp", 'fireball2', args, inject={}) | |
| def connect(self, allow_ssh=True): | |
| ''' activates the connection object over a socket ''' | |
| try: | |
| self.conn = socket.socket() | |
| self.conn.connect((self.host,self.fbport)) | |
| except: | |
| if allow_ssh: | |
| print "Falling back to ssh to startup accelerated mode" | |
| c = super(Connection,self).connect() | |
| self._execute_fb_module(c) | |
| return self.connect(allow_ssh=False) | |
| else: | |
| raise errors.Error("Failed to connect to %s:%s" % (self.host,self.fbport)) | |
| return self | |
| def exec_command(self, cmd): | |
| """ runs a command on the remote system """ | |
| ... |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fatal: [192.168.1.196] => Traceback (most recent call last): File "/opt/devel/ansible/lib/ansible/runner/__init__.py", line 373, in _executor exec_rc = self._executor_internal(host, new_stdin) File "/opt/devel/ansible/lib/ansible/runner/__init__.py", line 483, in _executor_internal complex_args=complex_args File "/opt/devel/ansible/lib/ansible/runner/__init__.py", line 602, in _executor_internal_inner conn = self.connector.connect(actual_host, actual_port, actual_user, actual_pass, actual_transport, actual_private_key_file) File "/opt/devel/ansible/lib/ansible/runner/connection.py", line 39, in connect self.active = conn.connect() File "/opt/devel/ansible/lib/ansible/runner/connection_plugins/fireball2.py", line 74, in connect self._execute_fb_module(self.ssh) File "/opt/devel/ansible/lib/ansible/runner/connection_plugins/fireball2.py", line 58, in _execute_fb_module return self.runner._execute_module(conn, "/tmp", 'fireball2', args, inject={}) File "/opt/devel/ansible/lib/ansible/runner/__init__.py", line 354, in _execute_module return ReturnData(conn=conn, result=data) File "/opt/devel/ansible/lib/ansible/runner/return_data.py", line 30, in __init__ self.host = conn.host AttributeError: 'super' object has no attribute 'host'