mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 07:54:00 -07:00
Move persistent connections to only use registered variables (#45616)
* Try to intuit proper plugins to send to ansible-connection * Move sub-plugins to init so that vars will be populated in executor * Fix connection unit tests
This commit is contained in:
parent
86c48205c4
commit
406b59aeba
10 changed files with 98 additions and 109 deletions
|
@ -217,6 +217,15 @@ class Connection(NetworkConnectionBase):
|
|||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
||||
self._network_os = self._network_os or 'default'
|
||||
|
||||
netconf = netconf_loader.get(self._network_os, self)
|
||||
if netconf:
|
||||
self._sub_plugins.append({'type': 'netconf', 'name': self._network_os, 'obj': netconf})
|
||||
display.display('loaded netconf plugin for network_os %s' % self._network_os, log_only=True)
|
||||
else:
|
||||
netconf = netconf_loader.get("default", self)
|
||||
self._sub_plugins.append({'type': 'netconf', 'name': 'default', 'obj': netconf})
|
||||
display.display('unable to load netconf plugin for network_os %s, falling back to default plugin' % self._network_os)
|
||||
display.display('network_os is set to %s' % self._network_os, log_only=True)
|
||||
|
||||
self._manager = None
|
||||
|
@ -246,8 +255,6 @@ class Connection(NetworkConnectionBase):
|
|||
return super(Connection, self).exec_command(cmd, in_data, sudoable)
|
||||
|
||||
def _connect(self):
|
||||
super(Connection, self)._connect()
|
||||
|
||||
display.display('ssh connection done, starting ncclient', log_only=True)
|
||||
|
||||
allow_agent = True
|
||||
|
@ -300,14 +307,6 @@ class Connection(NetworkConnectionBase):
|
|||
|
||||
self._connected = True
|
||||
|
||||
netconf = netconf_loader.get(self._network_os, self)
|
||||
if netconf:
|
||||
display.display('loaded netconf plugin for network_os %s' % self._network_os, log_only=True)
|
||||
else:
|
||||
netconf = netconf_loader.get("default", self)
|
||||
display.display('unable to load netconf plugin for network_os %s, falling back to default plugin' % self._network_os)
|
||||
self._implementation_plugins.append(netconf)
|
||||
|
||||
super(Connection, self)._connect()
|
||||
|
||||
return 0, to_bytes(self._manager.session_id, errors='surrogate_or_strict'), b''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue