lopes / netbox-scanner

A scanner util for NetBox
MIT License
159 stars 40 forks source link

update: README + netbox 2.9.x compatability #22

Closed ndom91 closed 3 years ago

ndom91 commented 3 years ago

So based upon the comments in #20 and my work getting this to work recently I made a few changes, hope you don't mind!

  1. Updated the README with info about manual tag creation and "Quick Start", because I found it difficult to decipher how to actually run the thing. Oh and I added instructions to create a venv before installing, standard python best practices.
  2. I commented out the line about tags when creating new IPs in nbs/__init__.py for now because the subroutine you mentioned to get the existing tag ID and use that instead doesn't exist yet and I'm not experienced enough with python to write it. This way it runs with current (and older) Netbox at least.
  3. I specified the full path to the directory and added the samples/nmap subdirectory already so people don't get confused (also the program was confused without the full path for me in that variable in the conf).
  4. Then I made a few changes to the nmap-scan.sh script. First of all, your shebang for just 'sh' didn't work on mine and my colleagues machine because sh wasn't symlinked to bash. The best practice here is to use #!/usr/bin/env bash. Also the NETWORKS variable isnt actually declared if you put spaces around the =, so I removed those. In addition, nmap wouldn't write a filename with an unescaped \ in it (from the full $net variable) so I made a temporary $rawNet variable which just chops off the last 3 chars of $net and writes the nmap file with the IP as suffix. Oh also tar was complaining because of unescaped . and : as well, so I dropped those from the TODAY variable.

This way it finally ran on my system on the latest Netbox (2.9.9) and it should still be compatible with older versions.

Like you mentioned in that issue, a real function to grab the ID of the required tag and use that in place of the name so we can uncomment that line again would be crucial.

Thanks 🎉

lopes commented 3 years ago

Excellent job!

Everyone must be aware that no tags will be written into NetBox in this version. For instance, in my environment, tags mark the data source (Nmap, Prime, NetXMS...), so it helps me troubleshooting.

For documentation purposes, from NetBox v2.9 tags are written through their IDs, so new routines must be created for tag creation and tag ID lookup (this ID will be written, not the tag name).