Report invalid connection types for network modules (#34755)

* Emit error on wrong connection type
This commit is contained in:
Nathaniel Case 2018-01-11 16:47:48 -05:00 committed by GitHub
parent 74ac1c2e4a
commit bd989b3088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 3 deletions

View file

@ -73,10 +73,12 @@ class ActionModule(_ActionModule):
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
task_vars['ansible_socket'] = socket_path
else:
elif self._play_context.connection in ('netconf', 'network_cli'):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
else:
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
# make sure we are in the right cli context which should be
# enable mode and not config module