Allow delegate_to if transport is not cli (#29945)

Fixes #29060

Allow delegate_to if transport is either nxapi or eapi.

Persistent connection uses `cli` transport and create
a local socket on control node. Hence delegate_to is not allowed
for `cli` transport.

However as `nxapi` and `eapi` transport does not use persistent connection
it is possible to use delegate_to in this case.
pull/4420/head
Ganesh Nalawade 2017-09-12 21:34:13 +05:30 committed by GitHub
parent b02937f3c3
commit 530988666a
3 changed files with 12 additions and 12 deletions

View File

@ -213,10 +213,10 @@ Will result in:
delegate_to vs ProxyCommand delegate_to vs ProxyCommand
--------------------------- ---------------------------
The new connection framework for Network Modules in Ansible 2.3 no longer supports the use of the The new connection framework for Network Modules in Ansible 2.3 that uses ``cli`` transport
``delegate_to`` directive. In order to use a bastion or intermediate jump host no longer supports the use of the ``delegate_to`` directive.
to connect to network devices, network modules now support the use of In order to use a bastion or intermediate jump host to connect to network devices over ``cli``
``ProxyCommand``. transport, network modules now support the use of ``ProxyCommand``.
To use ``ProxyCommand`` configure the proxy settings in the Ansible inventory To use ``ProxyCommand`` configure the proxy settings in the Ansible inventory
file to specify the proxy host. file to specify the proxy host.

View File

@ -37,16 +37,16 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
if self._play_context.connection != 'local': provider = load_provider(eos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
if self._play_context.connection != 'local' and transport == 'cli':
return dict( return dict(
failed=True, failed=True,
msg='invalid connection specified, expected connection=local, ' msg='invalid connection specified, expected connection=local, '
'got %s' % self._play_context.connection 'got %s' % self._play_context.connection
) )
provider = load_provider(eos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr) display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr)
if transport == 'cli': if transport == 'cli':

View File

@ -37,16 +37,16 @@ except ImportError:
class ActionModule(_ActionModule): class ActionModule(_ActionModule):
def run(self, tmp=None, task_vars=None): def run(self, tmp=None, task_vars=None):
if self._play_context.connection != 'local': provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
if self._play_context.connection != 'local' and transport == 'cli':
return dict( return dict(
failed=True, failed=True,
msg='invalid connection specified, expected connection=local, ' msg='invalid connection specified, expected connection=local, '
'got %s' % self._play_context.connection 'got %s' % self._play_context.connection
) )
provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr) display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr)
if transport == 'cli': if transport == 'cli':