bbird81 / Netbox-ipscanner

ip scan script for populating IPAM module in Netbox
MIT License
24 stars 9 forks source link

Help please #2

Closed tsorrento closed 1 year ago

tsorrento commented 1 year ago

Total noob here - trying out Netbox for our environment. So fargot lucky to get Netbox v3.4.3 running on a vm.

Looking to do some IP scan and yours look straight-forward to install which helps people like me a lot. Need help identify what modules I need to install. Running ubuntu 22.04.

Thank you in advance Troy

bbird81 commented 1 year ago

Hi! Fair point, I should have added requirements when committing (I will).

I'd say that the only libraries required are ipcalc networkscan

You might add them in local_requirements.txt in your netbox directory (/opt/netbox/ in my case) and then re-run upgrade.sh and restart service, something like

sudo sh -c "echo 'ipcalc' >> /opt/netbox/local_requirements.txt"
sudo sh -c "echo 'networkscan' >> /opt/netbox/local_requirements.txt"
sudo /opt/netbox/upgrade.sh
sudo systemctl restart netbox netbox-rq

OR add them manually (probably less secure), by activating netbox virtual envinronment and install them, like

source /opt/netbox/venv/bin/activate
sudo pip3 install ipcalc networkscan
sudo systemctl restart netbox netbox-rq

Hope this helps!

And don't forget to create a token in netbox and paste the value in line #4 of script in order to enable the script to write in netbox DB and change fqdn of your server @line 28.

If you still have problems, let me know and I'll try to help :)

tsorrento commented 1 year ago

Hello, Thanks so much for the prompt response. I tried both steps using sudo(first) then with the virtual environment.

When I tried with sudo, I get the following error: [image: image.png] I proceeded to restart netbox and netbox-rq - but got the error below when I went to "Other>Scripts" on the web UI. [image: image.png]

Doing the command in the virtual environment did not yield any error but still got the same error message as above.

I did put in the token in the netbox_ipscanner.py file, and line 28 has localhost, as shown below. [image: image.png]

Rebooted the server as my final and desperate attempt to make it work, but to no avail LOL

Thanks again for your time and input.

Troy

On Fri, Jan 27, 2023 at 12:41 PM bbird81 @.***> wrote:

Hi! Fair point, I should have added requirements when committing (I will).

I'd say that the only libraries required are ipcalc networkscan

You might add them in local_requirements.txt in your netbox directory (/opt/netbox/ in my case) and then re-run upgrade.sh and restart service, something like

sudo sh -c "echo 'ipcalc' >> /opt/netbox/local_requirements.txt" sudo sh -c "echo 'networkscan' >> /opt/netbox/local_requirements.txt" sudo /opt/netbox/upgrade.sh sudo systemctl restart netbox netbox-rq

OR add them manually (probably less secure), by activating netbox virtual envinronment and install them, like

source /opt/netbox/venv/bin/activate sudo pip3 install ipcalc networkscan

Hope this helps!

And don't forget to create a token in netbox and paste the value in line

4 of script in order to enable the script to write in netbox DB.

If you still have problems, let me know and I'll try to help :)

— Reply to this email directly, view it on GitHub https://github.com/bbird81/Netbox-ipscanner/issues/2#issuecomment-1406851741, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5QGO3N4H2SHQKWABBK6JIDWUQCFDANCNFSM6AAAAAAUI4LTQA . You are receiving this because you authored the thread.Message ID: @.***>

tsorrento commented 1 year ago

[[Trying one more time to see if pictures come up]]

Hello, Thanks so much for the prompt response. I tried both steps using sudo(first) then with the virtual environment.

When I tried with sudo, I get the following error: image

I proceeded to restart netbox and netbox-rq - but got the error below when I went to "Other>Scripts" on the web UI. image

Doing the command in the virtual environment did not yield any error but still got the same error message as above.

I did put in the token in the netbox_ipscanner.py file, and line 28 has localhost, as shown below. image

Rebooted the server as my final and desperate attempt to make it work, but to no avail LOL

Thanks again for your time and input.

Troy

bbird81 commented 1 year ago

Hi! Sorry I wasn't able to reply before...

So it seems like you have a couple of different issues...

The error about password authentication for root is about netbox backend beign unable to connect to the PostgreSQL database containing netbox objects. This doesn't really pertain to adding the script to your installation, but to netbox installation instead. One thing that I could say is that in the standard installation procedure of netbox you DO NOT use root to connect to the database, but an ad-hoc user instead (like "netbox"). This could be because you're using sudo, which in fact impersonates you as root which might have different configuration for the user... not sure.

The second error is an easy one! It just says you need also pynetbox module, which has to be added to local_requirements.txt the same way I described in my posts above. Sorry I didn't put it, I thought it was already there by default (looks like it's not). Adding pynetbox to local_requirements.txt and re-running the upgrade.sh script should do the trick.

Hope this helps you find your way to a working netbox with my script! :)

tsorrento commented 1 year ago

Hello again. Thank you so much for the help and providing the commands for the CLI. This really is very much appreciated. After 3 re-dos of ubuntu>Netbox installation on my lab vm machine, I think I'm making headway with the installation and making the script work. It really is as straight-forward as you stated in your description. I must have made some error following the Netbox installation instructions and I think it was something to do with pathing. I kept dropping into /opt/netbox/netbox/netbox/scripts where it's supposed to be just /opt/netbox/netbox/scripts. I cant believe I let myself make this mistake twice lol.

You are correct about the error I was getting on connecting to PostgreSQL. I was using root to run the commands and I was supposed to be in the venv environment using only netbox credentials. I really need to pay attention to the instructions properly :(

So after following the Netbox install instructions to the dot and running the syntax you provided here I have been able to run the script and get the desired outcome, exactly how the program was designed to do, The awesome part for me is that this is exactly what I was looking to use in my environment..

Thank you very much for the script. It is well written and works PERFECTLY.

Wishing you more blessings.....

Troy

bbird81 commented 1 year ago

Hi! :-) Don't bash yourself over not making it right the first time: the important thing is that you made it, you should be very proud of this! 💯

Thank you very much for your kind words, I greatly appreciate them, you really lit up my day!

Enjoy! :) :) :)