diff --git a/changelogs/fragments/junos_netconf_conn_error_msg.yml b/changelogs/fragments/junos_netconf_conn_error_msg.yml new file mode 100644 index 00000000000..a801ae7c9b3 --- /dev/null +++ b/changelogs/fragments/junos_netconf_conn_error_msg.yml @@ -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) diff --git a/lib/ansible/plugins/action/junos.py b/lib/ansible/plugins/action/junos.py index 6f617011039..64913c14be9 100644 --- a/lib/ansible/plugins/action/junos.py +++ b/lib/ansible/plugins/action/junos.py @@ -90,7 +90,8 @@ class ActionModule(_ActionModule): if any(provider.values()): 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. " "Please see http://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html" % (self._play_context.connection, self._task.action)}