netbox-community / Device-Type-Library-Import

This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
https://github.com/netbox-community/devicetype-library
MIT License
247 stars 74 forks source link

feat(docker): Move script to entrypoint #92

Closed titom73 closed 4 weeks ago

titom73 commented 1 year ago

Overview

Moving script to entrypoint make it easier to leverage script argument from CLI instead of always leveraging ENV variable.

docker run --rm --env-file=env-develop \
  ghcr.io/minitriga/netbox-device-type-library-import --vendors Arista,Juniper

ENV variable approach is unchanged and can still be used.

Changes:

danner26 commented 1 year ago

Running the script with no arguments would cause all items to be imported, I am not sure if that is desired behavior. I also have not looked into the use case for dockerizing this, could you provide some insight how you use this with docker?

titom73 commented 1 year ago

Today, current docker implementation does run an import for all vendors if nothing is specified

$ cat env-develop
NETBOX_URL=http://10.73.1.248:8000
NETBOX_TOKEN=hidden
REPO_URL=https://github.com/titom73/netbox-devicetype-library.git
REPO_BRANCH=homenetwork
IGNORE_SSL_ERRORS=False
#SLUGS=c9300-48u isr4431 isr4331

$ docker run --rm --env-file=env-develop ghcr.io/minitriga/netbox-device-type-library-import
Package Installed https://github.com/titom73/netbox-devicetype-library.git
No Vendors Specified, Gathering All Device-Types
106 Vendors Found

After adding VENDORS key in environment, both scripts have the same behavior:

$ cat env-develop
NETBOX_URL=http://10.73.1.248:8000
NETBOX_TOKEN=hidden
REPO_URL=https://github.com/titom73/netbox-devicetype-library.git
REPO_BRANCH=homenetwork
IGNORE_SSL_ERRORS=False
VENDORS=Arista

With current docker image

$ docker run --rm --env-file=env-develop ghcr.io/minitriga/netbox-device-type-library-import
Package Installed https://github.com/titom73/netbox-devicetype-library.git
Vendor Specified, Gathering All Matching Device-Types
1 Vendors Found
52 Device-Types Found

With new Dockerfile:

$ docker run --rm --env-file=env-develop ghcr.io/titom73/nb-device-importer:dev
Package Installed https://github.com/titom73/netbox-devicetype-library.git
1 Vendors Found
52 Device-Types Found

Idea of this change is to be able to use cli options in any situation: script invocation or docker execution.

danner26 commented 1 year ago

Looks like a good idea to me. So we have a bit more lifting to do, since the repo was moved from minitriga to netbox-community we need to setup the docker package and all of that good stuff. Please ping me if a few days go by and I havent reached back out about that yet