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

Updated netbox 'filters' persists when using reactor. #258

Open
n-holmstedt opened this issue Nov 3, 2021 · 1 comment
Open

Updated netbox 'filters' persists when using reactor. #258

n-holmstedt opened this issue Nov 3, 2021 · 1 comment
Labels
bug Something isn't working netbox reactor

Comments

@n-holmstedt
Copy link

n-holmstedt commented Nov 3, 2021

Describe the bug
This only occurs when using a reactor with the runner.proxy.execute.

The variable 'netbox_filter' in the targets-function of the netbox roster is a reference to the netbox filters in the global master options. When targeting a single device or using grains-filters, the global option object is updated and stored when name or levels is set.

Example:
1: Netbox filter in master config

netbox:
  token: <token>
  url: <url>
  filters:
    role: mwtransmission

2: Reactor executing targets a single device (tgt='mw-1') the 'netbox_filter' will be

[DEBUG   ] Querying NetBox with the following filters
[DEBUG   ] {'role': 'mwtransmission', name':'mw-1'}

3: Reactor executing globbing the devices (tgt='mw*') the 'netbox_filter will still be

[DEBUG   ] Querying NetBox with the following filters
[DEBUG   ] {'role': 'mwtransmission', name':'mw-1'}

Expected behavior
The netbox filter should have the starting values of the initial master config every time the 'targets'-function of the roster interface is called.

Versions Report

Salt Version:
           Salt: 3001.7
    Salt SProxy: 2021.6.1

Dependency Versions:
        Ansible: Not Installed
           cffi: 1.14.6
       dateutil: 2.8.2
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 3.0.1
     junos-eznc: 2.6.3
       jxmlease: Not Installed
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 1.0.2
         NAPALM: 3.2.0
       ncclient: 0.6.9
        Netmiko: 3.4.0
       paramiko: 2.8.0
      pycparser: 2.20
       pycrypto: Not Installed
   pycryptodome: 3.10.1
         pyeapi: 0.8.4
         pygit2: Not Installed
       PyNetBox: 6.1.3
          PyNSO: Not Installed
         Python: 3.7.10 (default, Apr 15 2021, 05:35:41)
   python-gnupg: Not Installed
         PyYAML: 5.4.1
          PyZMQ: 19.0.2
            scp: 0.14.1
          smmap: Not Installed
        textfsm: 1.1.0
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: alpine 3.12.7
         locale: UTF-8
        machine: x86_64
        release: 4.18.0-147.5.1.el8_1.x86_64
         system: Linux
        version: Alpine Linux 3.12.7

Additional context
Copying/de-referencing the options solves the issue.

netbox_filters = __opts__.get('netbox', {}).get('filters', {}).copy()
@n-holmstedt n-holmstedt added bug Something isn't working pending triage labels Nov 3, 2021
@mirceaulinic
Copy link
Owner

This also sounds like a bug, thanks for reporting @n-holmstedt. And yes, your solution sounds appropriate!

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

No branches or pull requests

2 participants