From 216e84c94e3b3099e4535dadf153aea96f3cfa83 Mon Sep 17 00:00:00 2001 From: niten Date: Mon, 11 Dec 2023 14:52:20 -0800 Subject: [PATCH] Only take one grafana & prometheus host --- lib/fudo/domains.nix | 26 +++++++++-------- lib/fudo/grafana.nix | 67 ++------------------------------------------ 2 files changed, 16 insertions(+), 77 deletions(-) diff --git a/lib/fudo/domains.nix b/lib/fudo/domains.nix index 8ff2a62..4aaa28c 100644 --- a/lib/fudo/domains.nix +++ b/lib/fudo/domains.nix @@ -48,11 +48,20 @@ let default = "admin@${domain}"; }; - grafana-hosts = mkOption { - type = listOf str; - description = - "List of hosts acting as Grafana metric analyzers. Requires prometheus hosts as well."; - default = [ ]; + metrics = mkOption { + type = nullOr (submodule { + options = { + grafanaHost = mkOption { + type = str; + description = "Hostname of the Grafana Metrics Analysis tool."; + }; + prometheusHost = mkOption { + type = str; + description = + "Hostname of the Prometheus Metrics Aggregator tool."; + }; + }; + }); }; log-aggregator = mkOption { @@ -146,13 +155,6 @@ let default = [ ]; }; - prometheus-hosts = mkOption { - type = listOf str; - description = - "List of hosts acting aas prometheus metric scrapers for hosts in this network."; - default = [ ]; - }; - primary-nameserver = mkOption { type = nullOr str; description = "Hostname of the primary nameserver for this domain."; diff --git a/lib/fudo/grafana.nix b/lib/fudo/grafana.nix index 2818920..84d4601 100644 --- a/lib/fudo/grafana.nix +++ b/lib/fudo/grafana.nix @@ -105,28 +105,6 @@ in { }; }; - database = { - name = mkOption { - type = str; - description = "Database name."; - default = "grafana"; - }; - hostname = mkOption { - type = str; - description = "Hostname of the database server."; - default = "localhost"; - }; - user = mkOption { - type = str; - description = "Database username."; - default = "grafana"; - }; - password-file = mkOption { - type = str; - description = "File containing the database user's password."; - }; - }; - oauth = let oauthOpts.options = { hostname = mkOption { @@ -250,51 +228,10 @@ in { }; database = { - host = cfg.database.hostname; - name = cfg.database.name; - user = cfg.database.user; - password = "$__file{${cfg.database.password-file}}"; - type = "postgres"; - ssl_mode = if cfg.private-network then "disable" else "require"; + type = "sqlite3"; + path = "${cfg.state-directory}/database.sqlite"; }; - # "ldap.auth" = mkIf (cfg.ldap != null) (let - # base = cfg.ldap.base-dn; - - # config-file = pkgs.writeText "grafana-ldap.toml" '' - # [[servers]] - # host = "${concatStringsSep " " cfg.ldap.hosts}" - # port = 389 - # start_tls = true - - # bind_dn = "uid=%s,ou=members,${base}" - - # search_filter = "(uid=%s)" - # search_base_dns = [ "ou=members,${base}" ] - - # group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))" - # group_search_base_dns = ["ou=groups,${base}"] - # group_search_filter_user_attribute = "uid" - - # [[servers.group_mappings]] - # group_dn = "cn=admin,ou=groups,${base}" - # org_role = "Admin" - # grafana_admin = true - - # [[servers.group_mappings]] - # group_dn = "cn=*,ou=groups,${base}" - # org_role = "Viewer" - # ''; - # in { - # enabled = true; - # allow_sign_up = true; - # config_file = "${config-file}"; - - # # AUTH_LDAP_ENABLED = "true"; - # # AUTH_LDAP_ALLOW_SIGN_UP = "true"; - # # AUTH_LDAP_CONFIG_FILE = config-file; - # }); - auth = mkIf (!isNull cfg.oauth) { signout_redirect_url = "https://${cfg.oauth.hostname}/application/o/${cfg.oauth.slug}/end-session/";