dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
89 stars 13 forks source link

Install Netdoc plugin on netbox host on docker #7

Closed dauphinpasdroit closed 1 year ago

dauphinpasdroit commented 1 year ago

Hey

I would like to reopen this issue we still have about installing netdoc in a netbox hosted on a docker.

I encountered this error:

[+] Building 10.2s (10/10) FINISHED
 => [internal] load build definition from Dockerfile-Plugins                                                                                                                                                                                                            0.1s
 => => transferring dockerfile: 564B                                                                                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                       0.0s
 => => transferring context: 159B                                                                                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/netboxcommunity/netbox:latest                                                                                                                                                                                                0.6s
 => [internal] load build context                                                                                                                                                                                                                                       0.0s
 => => transferring context: 172B                                                                                                                                                                                                                                       0.0s
 => CACHED [1/6] FROM docker.io/netboxcommunity/netbox:latest@sha256:f4b0d71cf4f518d4ab087b45c706e2ec82b9619b4071c6c3ccd880048d6a6be9                                                                                                                                   0.0s
 => [2/6] COPY ./plugin_requirements.txt /                                                                                                                                                                                                                              0.1s
 => [3/6] RUN /opt/netbox/venv/bin/pip install  --no-warn-script-location -r /plugin_requirements.txt                                                                                                                                                                   7.8s
 => [4/6] COPY configuration/configuration.py /etc/netbox/config/configuration.py                                                                                                                                                                                       0.1s
 => [5/6] COPY configuration/plugins.py /etc/netbox/config/plugins.py                                                                                                                                                                                                   0.1s
 => ERROR [6/6] RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input                                                                                                   1.3s
------
 > [6/6] RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input:
#0 0.883 🧬 loaded config '/etc/netbox/config/configuration.py'
#0 0.883 🧬 loaded config '/etc/netbox/config/extra.py'
#0 0.883 🧬 loaded config '/etc/netbox/config/logging.py'
#0 0.884 🧬 loaded config '/etc/netbox/config/plugins.py'
#0 1.137 Traceback (most recent call last):
#0 1.137   File "/opt/netbox/netbox/manage.py", line 10, in <module>
#0 1.137     execute_from_command_line(sys.argv)
#0 1.138   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
#0 1.138     utility.execute()
#0 1.138   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 386, in execute
#0 1.138     settings.INSTALLED_APPS
#0 1.138   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
#0 1.138     self._setup(name)
#0 1.138   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
#0 1.138     self._wrapped = Settings(settings_module)
#0 1.138   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__
#0 1.138     mod = importlib.import_module(self.SETTINGS_MODULE)
#0 1.138   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
#0 1.138     return _bootstrap._gcd_import(name[level:], package, level)
#0 1.138   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#0 1.138   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#0 1.138   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
#0 1.138   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
#0 1.138   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
#0 1.139   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#0 1.139   File "/opt/netbox/netbox/netbox/settings.py", line 711, in <module>
#0 1.139     plugin = importlib.import_module(plugin_name)
#0 1.139   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
#0 1.139     return _bootstrap._gcd_import(name[level:], package, level)
#0 1.139   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#0 1.139   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#0 1.139   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
#0 1.139   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
#0 1.139   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
#0 1.139   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#0 1.139   File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/__init__.py", line 61, in <module>
#0 1.139     shutil.copy(src_file, dst_file)
#0 1.139   File "/usr/lib/python3.10/shutil.py", line 417, in copy
#0 1.139     copyfile(src, dst, follow_symlinks=follow_symlinks)
#0 1.139   File "/usr/lib/python3.10/shutil.py", line 256, in copyfile
#0 1.139     with open(dst, 'wb') as fdst:
#0 1.139 FileNotFoundError: [Errno 2] No such file or directory: '/etc/netbox/scripts/NetDoc.py'
------
failed to solve: process "/bin/sh -c SECRET_KEY=\"dummydummydummydummydummydummydummydummydummydummy\" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input" did not complete successfully: exit code: 1

While running the command : docker compose build --no-cache

To deploy the plugin, I've followed this

Here is my Dockerfile-plugin

FROM netboxcommunity/netbox:latest

COPY ./plugin_requirements.txt /
RUN /opt/netbox/venv/bin/pip install  --no-warn-script-location -r /plugin_requirements.txt

# These lines are only required if your plugin has its own static files.
COPY configuration/configuration.py /etc/netbox/config/configuration.py
COPY configuration/plugins.py /etc/netbox/config/plugins.py
RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input

Here is the plugin_requirements.txt:

netdoc
ntc-templates
netbox_topology_views

And I added this lines in the configuration.py:

PLUGINS = ['netdoc', 'ntc-templates']
PLUGINS_CONFIG = {
    'netdoc': {
        # 'MAX_INGESTED_LOGS': 50,
        'NTC_TEMPLATES_DIR': '/opt/ntc-templates/ntc_templates/templates',
        # 'NORNIR_LOG': f'{settings.BASE_DIR}/nornir.log',
        # 'NORNIR_TIMEOUT': 300,
        # 'NORNIR_SKIP_LIST': [],
        # 'RAISE_ON_CDP_FAIL': True,
        # 'RAISE_ON_LLDP_FAIL': True,
    },
}

If you have any clue...

dainok commented 1 year ago

Check this: https://github.com/dainok/netdoc/wiki/NetBox-with-NetDoc-installation#installing-using-docker-compose

mamingzhi945 commented 1 year ago

I have the same problem.

mamingzhi945 commented 1 year ago

Check this: https://github.com/dainok/netdoc/wiki/NetBox-with-NetDoc-installation#installing-using-docker-compose

Dockerfile-Plugins?

dainok commented 1 year ago

@mamingzhi945

Uploaded: https://github.com/dainok/netdoc/tree/master/docker

mamingzhi945 commented 1 year ago

According to the example configuration, the following error is still reported:

=> [5/7] COPY configuration/configuration.py /etc/netbox/config/configuration.py                                                                                   0.1s
 => [6/7] COPY configuration/plugins.py /etc/netbox/config/plugins.py                                                                                               0.1s
 => ERROR [7/7] RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-in  2.5s
------
 > [7/7] RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input:
#0 0.498 🧬 loaded config '/etc/netbox/config/configuration.py'
#0 0.498 🧬 loaded config '/etc/netbox/config/extra.py'
#0 0.498 🧬 loaded config '/etc/netbox/config/logging.py'
#0 0.498 🧬 loaded config '/etc/netbox/config/plugins.py'
#0 2.390 Traceback (most recent call last):
#0 2.390   File "/opt/netbox/netbox/manage.py", line 10, in <module>
#0 2.390     execute_from_command_line(sys.argv)
#0 2.390   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
#0 2.390     utility.execute()
#0 2.390   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 386, in execute
#0 2.390     settings.INSTALLED_APPS
#0 2.390   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
#0 2.390     self._setup(name)
#0 2.390   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
#0 2.390     self._wrapped = Settings(settings_module)
#0 2.390   File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__
#0 2.391     mod = importlib.import_module(self.SETTINGS_MODULE)
#0 2.391   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
#0 2.391     return _bootstrap._gcd_import(name[level:], package, level)
#0 2.391   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#0 2.391   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#0 2.391   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
#0 2.391   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
#0 2.391   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
#0 2.391   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#0 2.391   File "/opt/netbox/netbox/netbox/settings.py", line 716, in <module>
#0 2.391     plugin = importlib.import_module(plugin_name)
#0 2.391   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
#0 2.391     return _bootstrap._gcd_import(name[level:], package, level)
#0 2.391   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#0 2.391   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#0 2.391   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
#0 2.391   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
#0 2.391   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
#0 2.391   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#0 2.392   File "/opt/netbox/venv/lib/python3.10/site-packages/netdoc/__init__.py", line 61, in <module>
#0 2.392     shutil.copy(src_file, dst_file)
#0 2.392   File "/usr/lib/python3.10/shutil.py", line 417, in copy
#0 2.392     copyfile(src, dst, follow_symlinks=follow_symlinks)
#0 2.392   File "/usr/lib/python3.10/shutil.py", line 256, in copyfile
#0 2.392     with open(dst, 'wb') as fdst:
#0 2.392 FileNotFoundError: [Errno 2] No such file or directory: '/etc/netbox/scripts/NetDoc.py'
------
failed to solve: executor failed running [/bin/sh -c SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input]: exit code: 1
mamingzhi945 commented 1 year ago

Do you want netdoc to specify the version?

dainok commented 1 year ago

In the default docker-compose (https://github.com/netbox-community/netbox-docker/blob/release/docker-compose.yml) scripts and reports are under /opt, not under /etc. Which docker-compose are you using?

dainok commented 1 year ago

Are you following the exact steps described here? https://github.com/dainok/netdoc/wiki/NetBox-with-NetDoc-installation#installing-using-docker-compose

mamingzhi945 commented 1 year ago

In the default docker-compose (https://github.com/netbox-community/netbox-docker/blob/release/docker-compose.yml) scripts and reports are under /opt, not under /etc. Which docker-compose are you using?

Thank you for your reminder, the path to scripts and reports has changed. my original netbox version is 3.2, I upgrade netbox-docker