Add junos connection type check (#38527) (#38579)

junos_netconf works only with connection=network_cli
Add check to report appropriate error if any other
connection type is used.
(cherry picked from commit 16c2d3717e)

Update Changelog fragments
pull/38596/head
Ganesh Nalawade 7 years ago committed by GitHub
parent 96efaa3ff3
commit 23e57fe095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- junos_netconf - Report error is wrong connection type is used for junos_netconf (https://github.com/ansible/ansible/pull/38527)

@ -90,7 +90,8 @@ class ActionModule(_ActionModule):
if any(provider.values()): if any(provider.values()):
display.warning('provider is unnecessary when using connection=%s and will be ignored' % self._play_context.connection) display.warning('provider is unnecessary when using connection=%s and will be ignored' % self._play_context.connection)
if self._play_context.connection == 'network_cli' and self._task.action not in CLI_SUPPORTED_MODULES: if (self._play_context.connection == 'network_cli' and self._task.action not in CLI_SUPPORTED_MODULES) or \
(self._play_context.connection == 'netconf' and self._task.action == 'junos_netconf'):
return {'failed': True, 'msg': "Connection type '%s' is not valid for '%s' module. " return {'failed': True, 'msg': "Connection type '%s' is not valid for '%s' module. "
"Please see http://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html" "Please see http://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html"
% (self._play_context.connection, self._task.action)} % (self._play_context.connection, self._task.action)}

Loading…
Cancel
Save