Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run state.apply with sproxy, returns "KeyError: '__opts__'" #253

Open
cyb0 opened this issue Sep 21, 2021 · 1 comment
Open

Cannot run state.apply with sproxy, returns "KeyError: '__opts__'" #253

cyb0 opened this issue Sep 21, 2021 · 1 comment
Labels
bug Something isn't working pending triage

Comments

@cyb0
Copy link

cyb0 commented Sep 21, 2021

Describe the bug

[root@iad1-saltlab-master-01 ~]# salt-sproxy fra2-sw-10 state.apply juniper.common.snmpv3

returns a KeyError with the latest version of sproxy.

fra2-sw-10:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/salt_sproxy/_runners/proxy.py", line 660, in salt_call
        ret = sa_proxy.functions[salt_function](*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2274, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
        return callable(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2289, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/state.py", line 792, in apply_
        return sls(mods, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/state.py", line 1391, in sls
        ret = st_.state.call_high(high_, orchestration_jid)
      File "/usr/lib/python3.6/site-packages/salt/state.py", line 3269, in call_high
        ret = self.call_chunks(chunks)
      File "/usr/lib/python3.6/site-packages/salt/state.py", line 2495, in call_chunks
        running = self.call_chunk(low, running, chunks)
      File "/usr/lib/python3.6/site-packages/salt/state.py", line 2856, in call_chunk
        low = self._mod_aggregate(low, running, chunks)
      File "/usr/lib/python3.6/site-packages/salt/state.py", line 852, in _mod_aggregate
        agg_opt = self.functions["config.option"]("state_aggregate")
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1241, in __call__
        return self.loader.run(run_func, *args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2274, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
        return callable(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2289, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/config.py", line 208, in option
        if value in __opts__:
      File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 81, in __contains__
        return item in self.value()
      File "/usr/lib/python3.6/site-packages/salt/loader_context.py", line 72, in value
        return loader.pack[self.name]
    KeyError: '__opts__'
ERROR: Minions returned with non-zero exit code

Steps To Reproduce
/srv/pillar/top.sls:

base:
  '*':
    - linux.iad1-saltlab-master-01.sproxy
  fra2-sw-10:
    - juniper.common.snmpv3

/srv/pillar/linux/iad1-saltlab-master-01/sproxy.sls:

proxy:
  proxytype: napalm
  username: <deleted>
  host: {{ opts.id }}
  multiprocessing: False
  always_alive: False
  optional_args:
    key_file: <deleted>

/srv/salt/top.sls:

base:
  fra2-sw-10:
    - juniper.common.snmpv3

/srv/salt/juniper/common/snmpv3.sls:

configure_snmpv3:
  netconfig.managed:
    - template_name: salt://juniper/templates/snmpv3.j2
    - replace: False
    - debug: True
    - test: True

If needed I can paste the jinja and static pillar, but they're working fine as I'm able to apply the same if it's running on a salt-proxy instead.

For roster I'm using a file:
/etc/salt/master.d/01-sproxy.conf:

roster: file
roster_file: /etc/salt/sproxy-devices.yaml

/etc/salt/sproxy-devices.yaml:

fra2-sw-10:
  driver: junos
  host: <deleted>

Expected behavior
It should work. :)

Versions Report
Print the output from salt-sproxy -V inside the backticks below:

Salt Version:
           Salt: 3003.3
    Salt SProxy: 2021.6.1
 
Dependency Versions:
        Ansible: Not Installed
           cffi: 1.14.5
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.3
     junos-eznc: 2.5.4
       jxmlease: 1.0.3
        libgit2: Not Installed
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
         NAPALM: 3.2.0
       ncclient: 0.6.10
        Netmiko: 3.3.3
       paramiko: 2.7.2
      pycparser: 2.20
       pycrypto: Not Installed
   pycryptodome: Not Installed
         pyeapi: 0.8.4
         pygit2: Not Installed
       PyNetBox: Not Installed
          PyNSO: Not Installed
         Python: 3.6.8 (default, Mar 19 2021, 05:13:41)
   python-gnupg: Not Installed
         PyYAML: 5.4.1
          PyZMQ: 19.0.0
            scp: 0.13.3
          smmap: Not Installed
        textfsm: 1.1.0
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.4
 
System Versions:
           dist: centos 8 
         locale: UTF-8
        machine: x86_64
        release: 4.18.0-240.15.1.el8_3.x86_64
         system: Linux
        version: CentOS Linux 8

Additional context
I can run commands via the sproxy to the remote system.
For example:
salt-sproxy -l debug fra2-sw-10 net.cli "show version"
is working properly so it's not an issue with the connectivity.

@cyb0 cyb0 added bug Something isn't working pending triage labels Sep 21, 2021
@cyb0
Copy link
Author

cyb0 commented Sep 21, 2021

I just figured out that if I run:
# salt-sproxy fra2-sw-10 state.apply juniper.common.snmpv3 test=False
it runs as it should and applies the config.
Any suggestions how to fix that?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

1 participant