Skip to content

Commit

Permalink
feat(Netbox): SSO (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan authored Dec 19, 2024
1 parent 3e644a5 commit ca00c72
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 196 deletions.
2 changes: 2 additions & 0 deletions kubernetes/argocd/applications/netbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
path: kubernetes/netbox/overlays/okd
repoURL: https://git.arthurvardevanyan.com/ArthurVardevanyan/HomeLab
targetRevision: HEAD
plugin:
name: argocd-vault-plugin-kustomize
syncPolicy:
syncOptions:
- CreateNamespace=true
189 changes: 0 additions & 189 deletions kubernetes/netbox/base/configmap.yaml

This file was deleted.

53 changes: 53 additions & 0 deletions kubernetes/netbox/base/configs/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import re
from pathlib import Path

import yaml


def _deep_merge(source, destination):
"""Inspired by https://stackoverflow.com/a/20666342"""
for key, value in source.items():
dst_value = destination.get(key)

if isinstance(value, dict) and isinstance(dst_value, dict):
_deep_merge(value, dst_value)
else:
destination[key] = value

return destination


def _load_yaml():
extraConfigBase = Path("/run/config/extra")
configFiles = [Path("/run/config/netbox/netbox.yaml")]

configFiles.extend(sorted(extraConfigBase.glob("*/*.yaml")))

for configFile in configFiles:
with open(configFile, "r") as f:
config = yaml.safe_load(f)

_deep_merge(config, globals())


def _load_secret(name, key):
path = "/run/secrets/{name}/{key}".format(name=name, key=key)
with open(path, "r") as f:
return f.read()


CORS_ORIGIN_REGEX_WHITELIST = list()
DATABASE = dict()
EMAIL = dict()
REDIS = dict()

_load_yaml()

DATABASE["PASSWORD"] = _load_secret("netbox", "db_password")
EMAIL["PASSWORD"] = _load_secret("netbox", "email_password")
REDIS["tasks"]["PASSWORD"] = _load_secret("netbox", "redis_tasks_password")
REDIS["caching"]["PASSWORD"] = _load_secret("netbox", "redis_cache_password")
SECRET_KEY = _load_secret("netbox", "secret_key")

# Post-process certain values
CORS_ORIGIN_REGEX_WHITELIST = [re.compile(r) for r in CORS_ORIGIN_REGEX_WHITELIST]
Loading

0 comments on commit ca00c72

Please sign in to comment.