forked from DGNum/infrastructure
Compare commits
5 commits
0eb813c8bf
...
2c88c2bad7
Author | SHA1 | Date | |
---|---|---|---|
2c88c2bad7 | |||
|
3494f609bb | ||
|
bf4bdf70df | ||
|
ac67107c6d | ||
efee0dd7b7 |
6 changed files with 77 additions and 54 deletions
35
modules/dgn-netbox-agent/01-batch-filter.patch
Normal file
35
modules/dgn-netbox-agent/01-batch-filter.patch
Normal file
|
@ -0,0 +1,35 @@
|
|||
diff --git a/netbox_agent/network.py b/netbox_agent/network.py
|
||||
index 673dfc1..8ef60aa 100644
|
||||
--- a/netbox_agent/network.py
|
||||
+++ b/netbox_agent/network.py
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
-from itertools import chain
|
||||
+from itertools import chain, islice
|
||||
|
||||
import netifaces
|
||||
from netaddr import IPAddress
|
||||
@@ -413,11 +413,17 @@ class Network(object):
|
||||
|
||||
# delete IP on netbox that are not known on this server
|
||||
if len(nb_nics):
|
||||
- netbox_ips = nb.ipam.ip_addresses.filter(
|
||||
- **{self.intf_type: [x.id for x in nb_nics]}
|
||||
- )
|
||||
+
|
||||
+ def batched(it, n):
|
||||
+ while batch := tuple(islice(it, n)):
|
||||
+ yield batch
|
||||
+
|
||||
+ netbox_ips = []
|
||||
+ for ids in batched((x.id for x in nb_nics), 25):
|
||||
+ netbox_ips += list(
|
||||
+ nb.ipam.ip_addresses.filter(**{self.intf_type: ids})
|
||||
+ )
|
||||
|
||||
- netbox_ips = list(netbox_ips)
|
||||
all_local_ips = list(chain.from_iterable([
|
||||
x['ip'] for x in self.nics if x['ip'] is not None
|
||||
]))
|
|
@ -14,9 +14,19 @@ in
|
|||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.dgn-netbox-agent.enable {
|
||||
nixpkgs.overlays = [
|
||||
(_: super: {
|
||||
netbox-agent = super.netbox-agent.overrideAttrs (old: {
|
||||
patches = (old.patches or [ ]) ++ [ ./01-batch-filter.patch ];
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
services.netbox-agent = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
netbox.url = "https://netbox.dgnum.eu/";
|
||||
network.ignore_interfaces = "(lo|dummy.*|docker.*|podman.*)";
|
||||
|
|
28
patches/03-nextcloud.patch
Normal file
28
patches/03-nextcloud.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
--- a/nixos/modules/services/web-apps/nextcloud.nix
|
||||
+++ b/nixos/modules/services/web-apps/nextcloud.nix
|
||||
@@ -131,6 +131,7 @@
|
||||
(mkRemovedOptionModule [ "services" "nextcloud" "disableImagemagick" ] ''
|
||||
Use services.nextcloud.enableImagemagick instead.
|
||||
'')
|
||||
+ (mkRenamedOptionModule [ "services" "nextcloud" "config" "objectstore" "s3" "autocreate" ] [ "services" "nextcloud" "config" "objectstore" "s3" "verify_bucket_exists" ])
|
||||
];
|
||||
|
||||
options.services.nextcloud = {
|
||||
@@ -487,7 +487,7 @@
|
||||
The name of the S3 bucket.
|
||||
'';
|
||||
};
|
||||
- autocreate = mkOption {
|
||||
+ verify_bucket_exists = mkOption {
|
||||
type = types.bool;
|
||||
description = lib.mdDoc ''
|
||||
Create the objectstore if it does not exist.
|
||||
@@ -820,7 +820,7 @@
|
||||
'class' => '\\OC\\Files\\ObjectStore\\S3',
|
||||
'arguments' => [
|
||||
'bucket' => '${s3.bucket}',
|
||||
- 'autocreate' => ${boolToString s3.autocreate},
|
||||
+ 'verify_bucket_exists' => ${boolToString s3.verify_bucket_exists},
|
||||
'key' => '${s3.key}',
|
||||
'secret' => nix_read_secret('${s3.secretFile}'),
|
||||
${optionalString (s3.hostname != null) "'hostname' => '${s3.hostname}',"}
|
|
@ -1,7 +1,7 @@
|
|||
let
|
||||
netboxAgent = {
|
||||
id = "244549";
|
||||
hash = "sha256-wWpp4br8bVxXobjuWrBY1XnxK+mOkuyU9Pr+UJ8CsvI=";
|
||||
hash = "sha256-SePkKEYQGDj6FpuyxZ+1ASeVPA02mCHf0G5i3koMdNw=";
|
||||
};
|
||||
in
|
||||
|
||||
|
@ -78,13 +78,13 @@ in
|
|||
# castopod: 1.6.4 -> 1.7.0 + ajout du support de loadcredentials
|
||||
{
|
||||
_type = "static";
|
||||
path = ./castopod.patch;
|
||||
path = ./01-castopod.patch;
|
||||
}
|
||||
|
||||
# nixos/nextcloud: Rename autocreate (a no-op) to verify_bucket_exists
|
||||
{
|
||||
id = 275165;
|
||||
hash = "sha256-XVq72jiLCDrZhADgyvI5y1y/5zlpX89vUBvxUolrYp8=";
|
||||
_type = "static";
|
||||
path = ./03-nextcloud.patch;
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
From 163fed297ed65a24241f190d8e954ce1877f9020 Mon Sep 17 00:00:00 2001
|
||||
From: Minijackson <minijackson@riseup.net>
|
||||
Date: Mon, 22 Jan 2024 16:17:57 +0100
|
||||
Subject: [PATCH] netbox: 3.6.9 -> 3.7.1
|
||||
|
||||
Or another way to see it:
|
||||
|
||||
netbox_3_7: init at 3.7.1
|
||||
|
||||
Make NetBox 3.7 the default version if stateVersion >= 24.05,
|
||||
switch upgrade test to test upgrade from 3.6 to 3.7,
|
||||
remove clearcache command for >=3.7.0,
|
||||
make reindex command mandatory
|
||||
---
|
||||
nixos/modules/services/web-apps/netbox.nix | 15 +++++++++------
|
||||
|
||||
diff --git a/nixos/modules/services/web-apps/netbox.nix b/nixos/modules/services/web-apps/netbox.nix
|
||||
index 72ec578146a764..b0921f461d2216 100644
|
||||
--- a/nixos/modules/services/web-apps/netbox.nix
|
||||
+++ b/nixos/modules/services/web-apps/netbox.nix
|
||||
@@ -75,7 +75,9 @@ in {
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default =
|
||||
- if lib.versionAtLeast config.system.stateVersion "23.11"
|
||||
+ if lib.versionAtLeast config.system.stateVersion "24.05"
|
||||
+ then pkgs.netbox_3_7
|
||||
+ else if lib.versionAtLeast config.system.stateVersion "23.11"
|
||||
then pkgs.netbox_3_6
|
||||
else if lib.versionAtLeast config.system.stateVersion "23.05"
|
||||
then pkgs.netbox_3_5
|
||||
@@ -306,12 +308,13 @@ in {
|
||||
${pkg}/bin/netbox trace_paths --no-input
|
||||
${pkg}/bin/netbox collectstatic --no-input
|
||||
${pkg}/bin/netbox remove_stale_contenttypes --no-input
|
||||
- # TODO: remove the condition when we remove netbox_3_3
|
||||
- ${lib.optionalString
|
||||
- (lib.versionAtLeast cfg.package.version "3.5.0")
|
||||
- "${pkg}/bin/netbox reindex --lazy"}
|
||||
+ ${pkg}/bin/netbox reindex --lazy
|
||||
${pkg}/bin/netbox clearsessions
|
||||
- ${pkg}/bin/netbox clearcache
|
||||
+ ${lib.optionalString
|
||||
+ # The clearcache command was removed in 3.7.0:
|
||||
+ # https://github.com/netbox-community/netbox/issues/14458
|
||||
+ (lib.versionOlder cfg.package.version "3.7.0")
|
||||
+ "${pkg}/bin/netbox clearcache"}
|
||||
|
||||
echo "${cfg.package.version}" > "$versionFile"
|
||||
'';
|
Loading…
Reference in a new issue