For example, NetBox v2.11.8 can be upgraded to version 3.3.2 following the steps below. However, a deployment of NetBox v2.10.10 or earlier must first be upgraded to any v2.11 release, and then to any v3.x release. (This is to accommodate the consolidation of database schema migrations effected by a major version change).
defread_configurations(config_module, config_dir, main_config):
loaded_configurations = []
main_config_path = abspath(f"{config_dir}/{main_config}.py")
if isfile(main_config_path):
_import(f"{config_module}.{main_config}", main_config_path, loaded_configurations)
else:
print(f"⚠️ Main configuration '{main_config_path}' not found.")
with scandir(config_dir) as it:
for f insorted(it, key=_filename):
ifnot f.is_file():
continueif f.name.startswith("__"):
continueifnot f.name.endswith(".py"):
continueif f.name == f"{main_config}.py":
continueif f.name == f"{config_dir}.py":
continue
module_name = f"{config_module}.{f.name[:-len('.py')]}".replace(".", "_")
_import(module_name, f.path, loaded_configurations)
iflen(loaded_configurations) == 0:
print(f"‼️ No configuration files found in '{config_dir}'.")
raiseImportError(f"No configuration files found in '{config_dir}'.")
return loaded_configurations
## Specific Parts# This section's code actually loads the various configuration files# into the module with the given name.# It contains the logic to resolve arbitrary configuration options by# levaraging dynamic programming using `__getattr__`.
_loaded_configurations = read_configurations(
config_dir="/etc/netbox/config/",
config_module="netbox.configuration",
main_config="configuration",
)
from os import environ
SOCIAL_AUTH_AZUREAD_OAUTH2_KEY = environ.get("SOCIAL_AUTH_AZUREAD_OAUTH2_KEY")
SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET = environ.get("SOCIAL_AUTH_AZUREAD_OAUTH2_SECRET")
/etc/netbox/config に入れておくように Docker イメージを編集し、
ARG TAG=latest
FROM netboxcommunity/netbox:${TAG}
COPY ./extra-configuration.py /etc/netbox/config
ビルドする。
docker build -t netbox:latest .
走らせると Azure AD ログインができるようになる。
docker run \-eREMOTE_AUTH_BACKEND='social_core.backends.azuread.AzureADOAuth2'\-eSOCIAL_AUTH_AZUREAD_OAUTH2_KEY='{Azure AD に登録した App Registration の Overview で表示される Application ID}'\-eSOCIAL_AUTH_AZUREAD_OAUTH2_SECRET='{Azure AD に登録した App Registration に対して登録したクライアントのシークレット値}'\
netbox:latest
まとめ
素の netboxcommunity/netbox Docker イメージには Azure AD との連携に必要な変数を定義できるようにしていない
拡張子が .py な名前のファイルに Azure AD との連携に必要な変数を環境変数から読み込むように定義してあげる
# dotfiles を再生成
$ home-manager switch
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in24.05
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in24.05
/nix/store/7871wampdlaqva7mpa616gkmjn4c38qj-home-manager-generation
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLaunchAgents
Activating checkLinkTargets
Activating writeBoundary
Activating linkGeneration
Cleaning up orphan links from /home/user
No change so reusing latest profile generation 139
Creating home file links in /home/user
Activating batCache
No themes were found in'/home/user/.config/bat/themes', using the default set
No syntaxes were found in'/home/user/.config/bat/syntaxes', using the default set.
Writing theme set to /home/user/.cache/bat/themes.bin ... okay
Writing syntax set to /home/user/.cache/bat/syntaxes.bin ... okay
Writing metadata to folder /home/user/.cache/bat ... okay
Activating copyFonts
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating onFilesChange
Activating setupLaunchAgents
There are 75 unread and relevant news items.
Read them by running the command"home-manager news".
# ~/.ssh/config を見てみる
$ cat ~/.ssh/config
Host gitlab
HostName gitlab.com
User git
# Node.js と pnpm を一時的にインストールした環境に入る
$ nix-shell -p nodejs nodePckages.pnpm
these 6 derivations will be built:
/nix/store/0i23yycgl4g3ysh919zrhqw6s7mv0clq-reconstructpackagelock.js.drv
/nix/store/10sbwpqks6vpixp3najqz2zr6bfbz2av-linkbins.js.drv
/nix/store/cay26jcn3vgnhsimhrpbqjmv39w5syg7-addintegrityfields.js.drv
/nix/store/dxwm67zm4j9rlprgy7qj7j10iywbharh-install-package.drv
/nix/store/vgc54qkgm1h9haaw95gkpahzss8hb1n3-pinpointDependencies.js.drv
/nix/store/win93b0d7agghd066d888bjbh5brrri0-pnpm-8.10.2.drv
these 5 paths will be fetched (46.54 MiB download, 408.80 MiB unpacked):
/nix/store/1ipdb6jghbj1zbnxwydghq8gkgf6v3ca-cctools-llvm-11.1.0-973.0.1-dev
/nix/store/gf6d8v8qj8rbpnyydyrv2m0vjcfw3bh6-cctools-port-973.0.1-dev
/nix/store/8sgv1kbxwx641j6v4sv63zh5p01w473k-node-sources
/nix/store/x551k64la7wmg4xj07yxfdd60wq2rd4y-pnpm-8.10.2.tgz
/nix/store/4ag0qy6w79b67xslwgi26ax3i91a19zc-tarWrapper
copying path '/nix/store/8sgv1kbxwx641j6v4sv63zh5p01w473k-node-sources' from 'https://cache.nixos.org'...
copying path '/nix/store/x551k64la7wmg4xj07yxfdd60wq2rd4y-pnpm-8.10.2.tgz' from 'https://cache.nixos.org'...
copying path '/nix/store/4ag0qy6w79b67xslwgi26ax3i91a19zc-tarWrapper' from 'https://cache.nixos.org'...
building '/nix/store/cay26jcn3vgnhsimhrpbqjmv39w5syg7-addintegrityfields.js.drv'...
building '/nix/store/dxwm67zm4j9rlprgy7qj7j10iywbharh-install-package.drv'...
building '/nix/store/10sbwpqks6vpixp3najqz2zr6bfbz2av-linkbins.js.drv'...
building '/nix/store/vgc54qkgm1h9haaw95gkpahzss8hb1n3-pinpointDependencies.js.drv'...
building '/nix/store/0i23yycgl4g3ysh919zrhqw6s7mv0clq-reconstructpackagelock.js.drv'...
copying path '/nix/store/gf6d8v8qj8rbpnyydyrv2m0vjcfw3bh6-cctools-port-973.0.1-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/1ipdb6jghbj1zbnxwydghq8gkgf6v3ca-cctools-llvm-11.1.0-973.0.1-dev' from 'https://cache.nixos.org'...
building '/nix/store/win93b0d7agghd066d888bjbh5brrri0-pnpm-8.10.2.drv'...
unpacking sources
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
installing
unpacking source archive /nix/store/x551k64la7wmg4xj07yxfdd60wq2rd4y-pnpm-8.10.2.tgz
pinpointing versions of dependencies...
patching script interpreter paths in .
./pnpm/bin/pnpx.cjs: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/bin/node"
./pnpm/bin/pnpm.cjs: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/bin/node"
./pnpm/dist/node_modules/node-gyp/bin/node-gyp.js: interpreter directive changed from "#!/usr/bin/env node" to "/nix/store/fwgfw6i5q1hv49bgfl96bmzv72l98khy-nodejs-18.18.2/bin/node"
./pnpm/dist/node-gyp-bin/node-gyp: interpreter directive changed from "#!/usr/bin/env sh" to "/nix/store/zzpm4317hn2y29rm46krsasaww9wxb1k-bash-5.2-p15/bin/sh"
No package-lock.json file found, reconstructing...
npm WARN config production Use `--omit=dev` instead.
rebuilt dependencies successfully
npm WARN config production Use `--omit=dev` instead.
up to date, audited 1 package in 183ms
found 0 vulnerabilities
linking bin 'pnpm'
linking bin 'pnpx'
post-installation fixup
checking for references to /private/tmp/nix-build-pnpm-8.10.2.drv-0/ in /nix/store/kyprrxixg263c82lzy9gmfpj97kkl32p-pnpm-8.10.2...
patching script interpreter paths in /nix/store/kyprrxixg263c82lzy9gmfpj97kkl32p-pnpm-8.10.2
rewriting symlink /nix/store/kyprrxixg263c82lzy9gmfpj97kkl32p-pnpm-8.10.2/bin to be relative to /nix/store/kyprrxixg263c82lzy9gmfpj97kkl32p-pnpm-8.10.2[nix-shell:~]$ pnpm --version8.10.2[nix-shell:~]$ node --version
v18.18.2
$ nix-channel --update
this derivation will be built:
/nix/store/ikk0zi83gc4x263imdgdx7d721wh33il-darwin.drv
building '/nix/store/ikk0zi83gc4x263imdgdx7d721wh33il-darwin.drv'...
this derivation will be built:
/nix/store/csfs0vgc39fwjsz6bx22a9iyx5zx3gwh-home-manager.drv
building '/nix/store/csfs0vgc39fwjsz6bx22a9iyx5zx3gwh-home-manager.drv'...
unpacking channels...
$ home-manager switch
# ここからは長い出力がある