Netbox

48 צפיות
מעבר להודעה הראשונה שלא נקראה

John Adams

לא נקראה,
18 בנוב׳ 2022, 16:32:4018.11.2022
עד Salt-users
Trying to get the netbox module to work but I get the following error:  The netbox execution module cannot be loaded: pynetbox library is not installed.

doing a pip list I see that it is installed.  What am I missing?

Thanks in advance.

Phipps, Thomas

לא נקראה,
18 בנוב׳ 2022, 16:36:2118.11.2022
עד salt-...@googlegroups.com

you don’t say what version. but pip might be the wrong command. it might be pointing to the wrong version of python.

use pip.install like salt-call pip.install pynetbox or if you are on a onedir version salt-pip install pynetbox


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/e88fee2a-8172-4880-af4f-c0f80f3d7379n%40googlegroups.com.

John Adams

לא נקראה,
21 בנוב׳ 2022, 14:59:2121.11.2022
עד Salt-users
Sorry I should've included more info.

Salt version is 3005.1

sudo salt-pip list
Package  Version
-------- -------
pynetbox 6.6.2

It's installed but I still get  'netbox' __virtual__ returned False: The netbox execution module cannot be loaded: pynetbox library is not installed.

John Adams

לא נקראה,
21 בנוב׳ 2022, 15:26:1021.11.2022
עד Salt-users
I double checked after rethinking this and it was NOT installed on the minion, but it was on the master.  After installing on the minion, I now get a  'NoneType' object is not subscriptable error no matter what function I call:

I.E. Passed invalid arguments to netbox.create_circuit_provider: 'NoneType' object is not subscriptable

Phipps, Thomas

לא נקראה,
21 בנוב׳ 2022, 15:56:0021.11.2022
עד salt-...@googlegroups.com
to troubleshoot that error you are going to need to get on the minion and run the command through salt-call with -l debug. netbox.command

We need to see the full tracepath for the error.

John Adams

לא נקראה,
21 בנוב׳ 2022, 16:13:3721.11.2022
עד Salt-users
Thanks for getting back to me.  I'm not very good with python and very new to salt but here's the debug output:

sudo salt-call -l debug netbox.get dcim devices id=100
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load log4mongo
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load raven
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/etc/salt/minion.d/minion.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/minion.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: MT-DOCKER
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load log4mongo
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load raven
[DEBUG   ] Configuration file path: /etc/salt/minion
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/etc/salt/minion.d/minion.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/minion.conf
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load pywintypes
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load dns
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load tldextract
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load tldextract
[DEBUG   ] The functions from module 'core' are being loaded by dir() on the loaded module
[DEBUG   ] The functions from module 'disks' are being loaded by dir() on the loaded module
[DEBUG   ] The functions from module 'extra' are being loaded by dir() on the loaded module
[DEBUG   ] The functions from module 'lvm' are being loaded by dir() on the loaded module
[DEBUG   ] The functions from module 'mdadm' are being loaded by dir() on the loaded module
[DEBUG   ] The functions from module 'minion_process' are being loaded by dir() on the loaded module
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load napalm
[DEBUG   ] The functions from module 'opts' are being loaded by dir() on the loaded module
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load pythoncom
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load win32com
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load win32api
[DEBUG   ] Override  __utils__: <module 'salt.loaded.int.grains.zfs' from '/opt/saltstack/salt/run/salt/grains/zfs.py'>
[DEBUG   ] The functions from module 'zfs' are being loaded by dir() on the loaded module
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string                                                                                                                           [106/812]
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] Elapsed time getting FQDNs: 0.04716372489929199 seconds
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load _bootlocale
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load lsb_release
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] Loading static grains from /etc/salt/grains
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] The functions from module 'zfs' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded zfs.is_supported
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] User provided environment variable 'LD_LIBRARY_PATH' with value '/opt/saltstack/salt/run' which is the value that PyInstaller set's. Removing it                                             [53/812]
[DEBUG   ] Setting environment variable 'LD_LIBRARY_PATH' to an empty string
[DEBUG   ] Connecting to master. Attempt 1 of 1
[DEBUG   ] Master URI: tcp://10.1.10.56:4506
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'MT-DOCKER', 'tcp://10.1.10.56:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (10203)
[DEBUG   ] Setting zmq_reconnect_ivl to '10203ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] salt.crypt._get_key_with_evict: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] SaltEvent PUB socket URI: /var/run/salt/minion/minion_event_a4ac9cc367_pub.ipc
[DEBUG   ] SaltEvent PULL socket URI: /var/run/salt/minion/minion_event_a4ac9cc367_pull.ipc
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] salt.crypt.verify_signature: Loading public key
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] salt.crypt.verify_signature: Verifying signature
[DEBUG   ] <salt.crypt.AsyncAuth object at 0x7f755c3ab5e0> Got new master aes key.
[DEBUG   ] Closing AsyncReqChannel instance
[DEBUG   ] Connecting the Minion to the Master publish port, using the URI: tcp://10.1.10.56:4505
[DEBUG   ] <salt.transport.zeromq.PublishClient object at 0x7f755c3ab8e0> connecting to tcp://10.1.10.56:4505
[DEBUG   ] Sending event: tag = __master_connected; data = {'master': '10.1.10.56', '_stamp': '2022-11-21T21:08:46.606289'}
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] Closing IPCMessageClient instance
[DEBUG   ] Determining pillar cache
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'MT-DOCKER', 'tcp://10.1.10.56:4506')
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] salt.crypt.verify_signature: Loading public key
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] salt.crypt.verify_signature: Verifying signature
[DEBUG   ] Closing AsyncReqChannel instance
[DEBUG   ] The functions from module 'jinja' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] The functions from module 'yaml' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load pynetbox
[DEBUG   ] TiamatPipPathFinder.find_spec: /opt/saltstack/salt/pypath/lib/python3.9/site-packages/pynetbox is a directory
[DEBUG   ] The functions from module 'netbox' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded netbox.get
[DEBUG   ] The functions from module 'direct_call' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded direct_call.execute
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load pywintypes
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load smbprotocol
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load pypsexec
[DEBUG   ] TiamatPipPathFinder.find_spec: First time trying to load winrm
[DEBUG   ] The functions from module 'config' are being loaded by dir() on the loaded module
[DEBUG   ] LazyLoaded config.get

Passed invalid arguments: 'NoneType' object is not subscriptable.

Usage:

    Get a single item from NetBox.

    app
        String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam``
    endpoint
        String of app endpoint, e.g., ``sites``, ``regions``, ``devices``

    Returns a single dictionary

    To get an item based on ID.

    .. code-block:: bash

        salt myminion netbox.get dcim devices id=123

    Or using named arguments that correspond with accepted filters on
    the NetBox endpoint.

    .. code-block:: bash

        salt myminion netbox.get dcim devices name=my-router

Traceback (most recent call last):
  File "salt/cli/caller.py", line 202, in call
    ret["return"] = self.minion.executors[fname](
  File "salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/run/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/run/salt/modules/netbox.py", line 188, in get_
    _get(
  File "/opt/saltstack/salt/run/salt/modules/netbox.py", line 117, in _get
    nb = _nb_obj(auth_required=auth_required)
  File "/opt/saltstack/salt/run/salt/modules/netbox.py", line 72, in _nb_obj
    return pynetbox.api(_config().get("url"), **pynb_kwargs)
  File "/opt/saltstack/salt/pypath/lib/python3.9/site-packages/pynetbox/core/api.py", line 86, in __init__
    base_url = "{}/api".format(url if url[-1] != "/" else url[:-1])
TypeError: 'NoneType' object is not subscriptable
[DEBUG   ] Restoring sys.argv to: ['/opt/saltstack/salt/run/run', '-l', 'debug', 'netbox.get', 'dcim', 'devices', 'id=100']

Phipps, Thomas

לא נקראה,
21 בנוב׳ 2022, 17:27:4221.11.2022
עד salt-...@googlegroups.com
that looks like the config for netbox isn't setup.

the minion does have the netbox config options set right?

John Adams

לא נקראה,
22 בנוב׳ 2022, 11:31:1822.11.2022
עד Salt-users
I set it using a pillar for the minion and it does show when I do a salt 'minion' pillar.items:

MT-DOCKER:
    ----------
    netbox:
        ----------
        api_token:
            blah blah blah
        api_url:
            https://netbox.middletownnj.org/api/

Phipps, Thomas

לא נקראה,
22 בנוב׳ 2022, 11:58:2222.11.2022
עד salt-...@googlegroups.com

Why did you put the api in front of the settings? https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.netbox.html

netbox:
    url: <NETBOX_URL>
    token: <NETBOX_USERNAME_API_TOKEN (OPTIONAL)>
    keyfile: </PATH/TO/NETBOX/KEY (OPTIONAL)>

as you can see it is url not api_url.


John Adams

לא נקראה,
22 בנוב׳ 2022, 12:28:2422.11.2022
עד Salt-users
Huh, I thought I did follow the documentation.  I'll fix and try again.  Thanks!

John Adams

לא נקראה,
22 בנוב׳ 2022, 12:33:5322.11.2022
עד Salt-users
That seems to be the problem, except now it fails due to our self signed cert : (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))

Anyway to set it to ignore cert errors?

Phipps, Thomas

לא נקראה,
22 בנוב׳ 2022, 12:35:0822.11.2022
עד salt-...@googlegroups.com
you might have been following the pillar documentation. which is completely different and for a different system. the pillar configuration goes on the master and can only be in the master config. see https://docs.saltproject.io/en/latest/ref/pillar/all/salt.pillar.netbox.html



השב לכולם
השב למחבר
העבר לנמענים
0 הודעות חדשות