dmulyalin / salt-nornir

SALTSTACK Nornir based proxy minion, execution, state and runner modules
MIT License
27 stars 3 forks source link

Errors while running `nr.learn` #7

Closed abhi1693 closed 2 years ago

abhi1693 commented 2 years ago

From the documentation's example, I ran salt-call nr.learn "show version" "show int brief" tf="cli_facts" fun="cli and was presented with the following error. This happens for all nr.learn commands.

Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    load_entry_point('salt==3004.1', 'console_scripts', 'salt-call')()
  File "/usr/lib/python3/dist-packages/salt/scripts.py", line 432, in salt_call
    client.run()
  File "/usr/lib/python3/dist-packages/salt/cli/call.py", line 55, in run
    caller.run()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 111, in run
    ret = self.call()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 218, in call
    ret["return"] = self.minion.executors[fname](
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/salt_nornir/modules/nornir_proxy_execution_module.py", line 2210, in learn
    return globals()[fun](*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/salt_nornir/modules/nornir_proxy_execution_module.py", line 1135, in cli
    default_kwargs = __proxy__["nornir.nr_data"]("nr_cli")
  File "/usr/lib/python3/dist-packages/salt/loader/context.py", line 78, in __getitem__
    return self.value()[item]
  File "/usr/lib/python3/dist-packages/salt/utils/context.py", line 221, in __getitem__
    return self._dict()[key]
KeyError: 'nornir.nr_data'
root@ubuntu:~# pip show nornir
Name: nornir
Version: 3.3.0
Summary: Pluggable multi-threaded framework with inventory management to help operate collections of devices
Home-page: https://github.com/nornir-automation/nornir
Author: David Barroso
Author-email: dbarrosop@dravetech.com
License: Apache 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: typing-extensions, ruamel.yaml, mypy-extensions, importlib-metadata
Required-by: salt-nornir, nornir-utils, nornir-scrapli, nornir-salt, nornir-napalm
root@ubuntu:~# 
dmulyalin commented 2 years ago

Are you using salt-call because you running in masterless mode? Never tried to use it in such a way to be honest, but looks like for some reason __proxy__["nornir.nr_data"] dictionary does not have "nornir.nr_data" key.

What about other function - cli, cfg - do they work at all?

Not sure, proxy-minions, do they support masterless mode at all?

abhi1693 commented 2 years ago

I'm not in masterless mode, but I thought to directly invoke the commands on the minion to quickly test the examples from the documentation. I wasn't aware that it is not supported.