From a5428f1d2eded85828453dbc3d44272fc9a77730 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 6 Oct 2024 18:52:28 -0500 Subject: [PATCH] netbox: fix container permissions Signed-off-by: Myned --- options/custom/containers/netbox/Dockerfile | 7 ++++++ options/custom/containers/netbox/default.nix | 22 ++++++++++--------- options/custom/containers/netbox/extra.py | 5 +++-- .../containers/netbox/plugin_requirements.txt | 4 ++-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/options/custom/containers/netbox/Dockerfile b/options/custom/containers/netbox/Dockerfile index d2b24ee..92213f3 100644 --- a/options/custom/containers/netbox/Dockerfile +++ b/options/custom/containers/netbox/Dockerfile @@ -1,5 +1,12 @@ # TODO: Upgrade to v4.1 when supported by netbox-acls FROM docker.io/netboxcommunity/netbox:v4.0.11 +# Install extra configuration +COPY ./extra.py /etc/netbox/config/ + +# Install plugin modules COPY ./plugin_requirements.txt /opt/netbox/ RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /opt/netbox/plugin_requirements.txt + +# Install plugin static files +RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input diff --git a/options/custom/containers/netbox/default.nix b/options/custom/containers/netbox/default.nix index b171804..640854c 100644 --- a/options/custom/containers/netbox/default.nix +++ b/options/custom/containers/netbox/default.nix @@ -33,19 +33,21 @@ in { container_name = "netbox"; depends_on = ["cache" "db"]; env_file = [config.age.secrets."${config.custom.profile}/netbox/.env".path]; + image = "localhost/netbox"; # Built image restart = "unless-stopped"; - volumes = ["${./extra.py}:/etc/netbox/config/extra.py"]; - - # https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins - #!! Context modifications require a rebuild - #?? arion-netbox build - build.context = "${./.}"; + user = "unit:root"; + volumes = ["${config.custom.containers.directory}/netbox/media:/opt/netbox/netbox/media"]; }; in { netbox.service = netbox // { ports = ["8585:8080"]; + + # https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins + #!! Context modifications require a rebuild + #?? arion-netbox build --no-cache + build.context = "${./.}"; }; housekeeping.service = @@ -77,12 +79,12 @@ in { env_file = [config.age.secrets."${config.custom.profile}/netbox/db.env".path]; image = "docker.io/postgres:16"; restart = "unless-stopped"; - - volumes = [ - "${config.custom.containers.directory}/netbox/db:/var/lib/postgresql/data" - ]; + volumes = ["${config.custom.containers.directory}/netbox/db:/var/lib/postgresql/data"]; }; }; }; + + #!! Required for correct volume permissions + systemd.tmpfiles.rules = ["z ${config.custom.containers.directory}/netbox/media 0770 999 root"]; # unit:root }; } diff --git a/options/custom/containers/netbox/extra.py b/options/custom/containers/netbox/extra.py index b6f3f34..ca95d5f 100644 --- a/options/custom/containers/netbox/extra.py +++ b/options/custom/containers/netbox/extra.py @@ -8,11 +8,12 @@ LOGIN_PERSISTENCE = True # https://github.com/netbox-community/pynetbox/pull/641 LOGIN_REQUIRED = True +MEDIA_ROOT = "/opt/netbox/netbox/media" # Default /opt/netbox/media TIME_ZONE = "America/Chicago" PLUGINS = [ "netbox_acls", - "netbox_attachments", + # // "netbox_attachments", "netbox_dns", "netbox_interface_synchronization", "netbox_lists", @@ -21,7 +22,7 @@ PLUGINS = [ # // "netbox_routing", "netbox_secrets", "netbox_topology_views", - "slurpit_netbox", + # // "slurpit_netbox", ] PLUGINS_CONFIG = { diff --git a/options/custom/containers/netbox/plugin_requirements.txt b/options/custom/containers/netbox/plugin_requirements.txt index c00a53b..43f7a29 100644 --- a/options/custom/containers/netbox/plugin_requirements.txt +++ b/options/custom/containers/netbox/plugin_requirements.txt @@ -1,5 +1,5 @@ netbox-acls == 1.6.* # https://github.com/netbox-community/netbox-acls -netbox-attachments == 5.1.* # https://github.com/Kani999/netbox-attachments +#// netbox-attachments == 5.1.* # https://github.com/Kani999/netbox-attachments netbox-interface-synchronization == 4.0.* # https://github.com/NetTech2001/netbox-interface-synchronization netbox-lists == 4.0.* # https://github.com/devon-mar/netbox-lists netbox-otp-plugin == 1.3.* # https://github.com/k1nky/netbox-otp-plugin @@ -8,4 +8,4 @@ netbox-reorder-rack == 1.1.* # https://github.com/netbox-community/netbox-reorde #// netbox-routing # https://github.com/DanSheps/netbox-routing netbox-secrets == 2.0.* # https://github.com/Onemind-Services-LLC/netbox-secrets netbox-topology-views == 4.0.* # https://github.com/netbox-community/netbox-topology-views -slurpit_netbox == 0.9.* # https://gitlab.com/slurpit.io/slurpit-netbox +#// slurpit_netbox == 0.9.* # https://gitlab.com/slurpit.io/slurpit-netbox