mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-09 09:49:09 -07:00
adds feature to allow connection to set action plugin (#18762)
Connection plugin can define default action plugin to use by providing action_handler instance variable. This will override the default action plugin normal
This commit is contained in:
parent
0cef38cf02
commit
ad99d52679
2 changed files with 10 additions and 1 deletions
|
@ -30,12 +30,19 @@ from ansible.plugins import terminal_loader
|
|||
from ansible.plugins.connection import ensure_connect
|
||||
from ansible.plugins.connection.paramiko_ssh import Connection as _Connection
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
|
||||
class Connection(_Connection):
|
||||
''' CLI (shell) SSH connections on Paramiko '''
|
||||
|
||||
transport = 'network_cli'
|
||||
has_pipelining = False
|
||||
action_handler = 'network'
|
||||
|
||||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
@ -97,6 +104,7 @@ class Connection(_Connection):
|
|||
self._terminal.on_authorize(passwd=auth_pass)
|
||||
|
||||
def close(self):
|
||||
display.vvv('closing connection', host=self._play_context.remote_addr)
|
||||
self.close_shell()
|
||||
super(Connection, self).close()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue