Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/unifi-poller: add unifi-poller service #95994

Closed
wants to merge 2 commits into from

Conversation

bachp
Copy link
Member

@bachp bachp commented Aug 22, 2020

Motivation for this change

Replace unifi_exporter and resolve #88846

It is not a drop in replacement so I added it in addition to the old unifi exporter.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

nixos/modules/services/monitoring/unifi-poller.nix Outdated Show resolved Hide resolved
description = "Username used to access the unifi controller. The user needs read access.";
example = "unifipoller";
};
passwordFile = mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is almost no safer than storing a password in the nix store because of DynamicUser...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the alternatives?

Copy link
Member

@aanderse aanderse Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally using LoadCredential. Until that lands in NixOS the better option would be a script in ExecStart which is executed as root and copies passwordFile into the private WorkingDirectoryStateDirectory (or such) folder so the DynamicUser service could read it (but no one else). As a last resort you could avoid DynamicUser... but then you are foregoing certain security features in favour of a secure passwordFile option which is not ideal.

The module is somewhat opionionanted in the sense that it supports
multiple controllers only in the recommnded approach described in
https://github.com/unifi-poller/unifi-poller/wiki/Prometheus#approach-4-recommended

In the longterm this should replace unifi-exporter which is no longer
maintained.
@bachp bachp marked this pull request as ready for review August 23, 2020 20:36
@lheckemann
Copy link
Member

lheckemann commented Sep 3, 2020

Thanks for this!

I think I prefer the JSON-based approach in #96830 — it uses existing structured-data mechanisms and is less susceptible to escaping issues than generating shell script, as well as providing integration with the prometheus exporter structure and a test, albeit simple. Does this cover any use cases I may have missed which #96830 doesn't?

@bachp
Copy link
Member Author

bachp commented Sep 6, 2020

@lheckemann I don't think it's missing anything.

Closing in favor of #96830

@bachp bachp closed this Sep 6, 2020
@bachp bachp deleted the unifi-poller branch September 6, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace unifi_exporter with unifi-poller (prometheus exporter)
3 participants