sol1 / icingaweb2-module-netbox

Netbox importer for director, and integration with netbox
28 stars 6 forks source link

Netbox integration is not working #3

Closed madhusudhanarya closed 3 years ago

madhusudhanarya commented 3 years ago

Icinga2 version: 2.8.2 PHP version: 7.3.20 Netbox version: 2.8.9

Installed the plugin and then provided the all required info requested by netbox module as show in the screenshot. msedge_2020-12-21_20-53-55

Added sync rules as shown in below screenshot.

msedge_2020-12-21_20-54-44

When i click on "Check for changes" or "Trigger import run", an error is shown after sometime as shown in below screenshot. msedge_2020-12-21_20-53-27

Restarted system and icinga2 daemon. No luck.

davekempe commented 3 years ago

Hi I'm not sure you have the version in this repo, as the Munge Fields option is missing. This tells me you don't have the latest code, please try the code from this repo. In addition, there should be no reason the netbox importer stops the icinga daemon. They aren't connected - any director import module just pulls data from the source and puts it in the director database. It doesn't get committed until you deploy the config. So your problem of Icinga stopping is not connected.

madhusudhanarya commented 3 years ago

I have installed the latest module from the repo.

[root@test-vm tmp]# wget https://github.com/sol1/icingaweb2-module-netbox/archive/v1.3.0.tar.gz --2020-12-23 08:52:26-- https://github.com/sol1/icingaweb2-module-netbox/archive/v1.3.0.tar.gz Resolving github.com (github.com)... 13.234.176.102 Connecting to github.com (github.com)|13.234.176.102|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/sol1/icingaweb2-module-netbox/tar.gz/v1.3.0 [following] --2020-12-23 08:52:26-- https://codeload.github.com/sol1/icingaweb2-module-netbox/tar.gz/v1.3.0 Resolving codeload.github.com (codeload.github.com)... 13.233.43.20 Connecting to codeload.github.com (codeload.github.com)|13.233.43.20|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/x-gzip] Saving to: ‘v1.3.0.tar.gz’

[  <=>                                                                                                                       ] 96,601       168KB/s   in 0.6s   

2020-12-23 08:52:28 (168 KB/s) - ‘v1.3.0.tar.gz’ saved [96601]

[root@test-vm tmp]# tar -zxf v1.3.0.tar.gz [root@test-vm tmp]# mv icingaweb2-module-netbox-1.3.0 /usr/share/icingaweb2/modules/netbox [root@test-vm tmp]# icingacli module enable netbox

Reloaded director after enabling the module.

When i check the version of the netbox module, its listing 1.2 and NOT 1.3.

[root@test-vm tmp]# icingacli module list | grep netbox netbox 1.2.0 enabled Import devices, sites and other objects from Netbox

While adding netbox source, i still don'e see Munge Field option.

msedge_2020-12-23_09-02-22

I am missing steps here?

ollytom commented 3 years ago

Double check the command used to install the module:

mv icingaweb2-module-netbox-1.3.0 /usr/share/icingaweb2/modules/netbox

This moves directory icingaweb2-module-netbox-1.3.0 under netbox, which is not what we want. The parent directory should be /usr/share/icingaweb2/modules. Admittedly the instructions in the README don't take into account upgrading from one release to another.

First, remove the existing installation:

rm -r /usr/share/icingaweb2/modules/netbox

Then install the new version:

curl -L https://github.com/sol1/icingaweb2-module-netbox/archive/v1.3.0.tar.gz | tar xz
mv icingaweb2-module-netbox-1.3.0 /usr/share/icingaweb2/modules/netbox

I've submitted a patch to include this in the documentation: https://github.com/sol1/icingaweb2-module-netbox/pull/4

davekempe commented 3 years ago

oh thanks @ollytom ! nice work.

ollytom commented 3 years ago

No worries. Got a whole lot of sweet FA to do during this lockdown so, you know, thought may as well give back to the community ;) haha merry xmas :)

madhusudhanarya commented 3 years ago

I precisely followed the steps as you have described. Please find below screenshot.

Termius_2020-12-23_19-35-21

  1. Removed existing directory
  2. Downloaded the source and extracted it
  3. Moved it under modules directory

I have ensured that, netbox module directory contains the files and NOT icingaweb2-module-netbox-1.3.0 directory. You can see the output of ls command against netbox directory.

Even after following the instruction, still not seeing Munge Filed option in the web.

msedge_2020-12-23_19-34-58

Once more thing i observed is, the last modification date of all the files/directories in the source (v1.3.0.tar.gz) is showing as March 17 but your latest commit is on Nov 20. Not sure if this is some issue at my side.

davekempe commented 3 years ago

Can you simply try and pull from git master? It should work pretty much the same.

ollytom commented 3 years ago

Once more thing i observed is, the last modification date of all the files/directories in the source (v1.3.0.tar.gz) is showing as March 17 but your latest commit is on Nov 20. Not sure if this is some issue at my side.

Nice spotting. That's where the confusion is. No issue at your side; release v1.3.0 points to a revision made back in March (8bd4e46). There have been no tagged revisions since then, so we are downloading old code without the new 'munge field' features.

For the maintainers there are a couple of ways forward:

  1. Tag a revision and make a new release e.g. v1.4.0. This can be done using the git CLI and/or in the GitHub web UI. See the help docs. A bit more work, nice to publish on Icinga Exchange.
  2. Abandon versioned releases altogether and only support the latest checkout from version control. Less work, simplifies install instructions.

Hope that helps :)

davekempe commented 3 years ago

yep sorry about that. git pull from master is all good.

madhusudhanarya commented 3 years ago

Did a git pull. Now i was able to add netbox source. When i try "Check for changes", getting below error.

msedge_2020-12-24_09-19-34

And here is netbox options used.

msedge_2020-12-24_09-20-53

sol1-matt commented 3 years ago

I suspect that the problem here is the version of netbox you are using is older than the code supports, I've taken to tagging the release with the netbox version it runs against (https://github.com/sol1/icingaweb2-module-netbox/tags).

This doesn't mean that other netbox versions won't work just that the changes were targeted to the netbox version the tag matches. The current release is works on Netbox v2.10.3 and above, I've run it on 2.11.3 successfully.

Most changes to this module currently revolve around small changes in the Netbox api.

If you upgrade your netbox version to 2.10 the options used should working without issue, I've run this code on multiple netbox/icinga setups.