mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-01 12:40:22 -07:00
Junos fixes (#22423)
* Fixes for junos_config errors * Check transport settings for core Junos * Don't pop from the same list you iterate over * use of persistent connections are now explicitly enabled in junos * modules must now explicitly enable persistent connections * adds rpc support to junos_command fixes #22166
This commit is contained in:
parent
17fc6832ca
commit
1825406e1e
7 changed files with 207 additions and 86 deletions
|
@ -25,7 +25,7 @@ import copy
|
|||
|
||||
from ansible.plugins.action.normal import ActionModule as _ActionModule
|
||||
from ansible.utils.path import unfrackpath
|
||||
from ansible.plugins import connection_loader
|
||||
from ansible.plugins import connection_loader, module_loader
|
||||
from ansible.compat.six import iteritems
|
||||
from ansible.module_utils.junos import junos_argument_spec
|
||||
from ansible.module_utils.basic import AnsibleFallbackNotFound
|
||||
|
@ -50,12 +50,18 @@ class ActionModule(_ActionModule):
|
|||
'got %s' % self._play_context.connection
|
||||
)
|
||||
|
||||
module = module_loader._load_module_source(self._task.action, module_loader.find_plugin(self._task.action))
|
||||
|
||||
if not getattr(module, 'USE_PERSISTENT_CONNECTION', False):
|
||||
return super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
provider = self.load_provider()
|
||||
transport = provider['transport'] or 'cli'
|
||||
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.network_os = 'junos'
|
||||
|
||||
if self._task.action in ('junos_command', 'junos_netconf', 'junos_config', '_junos_template'):
|
||||
if transport == 'cli':
|
||||
pc.connection = 'network_cli'
|
||||
pc.port = provider['port'] or self._play_context.port or 22
|
||||
else:
|
||||
|
@ -82,6 +88,7 @@ class ActionModule(_ActionModule):
|
|||
|
||||
if rc != 0:
|
||||
return {'failed': True, 'msg': 'unable to connect to control socket'}
|
||||
|
||||
elif pc.connection == 'network_cli':
|
||||
# make sure we are in the right cli context which should be
|
||||
# enable mode and not config module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue