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

[WIP] icinga2: init at 2.7.0 #29577

Closed
wants to merge 8 commits into from
Closed

Conversation

disassembler
Copy link
Member

@disassembler disassembler commented Sep 19, 2017

Motivation for this change

working on adding icinga client and server to nixos.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@@ -11548,6 +11548,8 @@ with pkgs;
erlang = erlang_basho_R16B02;
};

icinga2_client = callPackage ../servers/monitoring/icinga2/client.nix { };
Copy link
Member

Choose a reason for hiding this comment

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

Why not just called it icinga2 and the other package icinga2-web later?

Copy link
Member

Choose a reason for hiding this comment

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

This is how upstream names it.

environment = pkgs.writeText "icinga-env" ''
DAEMON=${pkgs.icinga2}/sbin/icinga2
ICINGA2_CONFIG_FILE=/etc/icinga2/icinga2.conf
ICINGA2_RUN_DIR=/var/run
Copy link
Member

Choose a reason for hiding this comment

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

/var/run is deprecated - should be /run

cfg = config.services.icinga2;
environment = pkgs.writeText "icinga-env" ''
DAEMON=${pkgs.icinga2}/sbin/icinga2
ICINGA2_CONFIG_FILE=/etc/icinga2/icinga2.conf
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we "pollute" /etc? Can't we write the config to the nix store?

Copy link
Member Author

Choose a reason for hiding this comment

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

merely debugging trying to get the thing to run in the first place. My end goal is to have it be a src the user can define as say a git repository or tarball somewhere.

let
cfg = config.services.icinga2;
environment = pkgs.writeText "icinga-env" ''
DAEMON=${pkgs.icinga2}/sbin/icinga2
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be lib.getBin pkgs.icinga2

DAEMON=${pkgs.icinga2}/sbin/icinga2
ICINGA2_CONFIG_FILE=/etc/icinga2/icinga2.conf
ICINGA2_RUN_DIR=/var/run
ICINGA2_STATE_DIR=/var/icinga2
Copy link
Member

Choose a reason for hiding this comment

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

Should be /var/lib/icinga2 to be in line with other packages.

Copy link
Member

Choose a reason for hiding this comment

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

What does upstream here? This should be the default otherwise there is an important reason.

Copy link
Member

Choose a reason for hiding this comment

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

Most of the NixOS stuff ends up in /var/lib/[package] so if all we need to do is define that variable, shouldn't we choose to be consistent with ourselves instead of just following upstream?

Copy link
Member

@Mic92 Mic92 Sep 26, 2017

Choose a reason for hiding this comment

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

Then we break documentation and third party-tools, which I find a more important aim then the aesthetics of consistency. We should always have an important reason before we break with upstream.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's /var/lib/icinga2 on centos 7 icinga instance I have, I'm changing it here.

EnvironmentFile = environment;
ExecStart = "${pkgs.icinga2}/bin/icinga2 daemon -d";
ExecReload = "${pkgs.icinga2}/lib/icinga2/safe-reload ${environment}";
PIDFile = "/var/run/icinga2/icinga2.pid";
Copy link
Member

Choose a reason for hiding this comment

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

You should use RuntimeDirectory = "icinga2"; to have /run/icinga2 created for you.

export MYSQL_INCLUDE_DIR=${mysql}/include/mysql
'';

buildInputs = [ cmake boost yajl openssl flex bison mysql postgresql ];
Copy link
Member

Choose a reason for hiding this comment

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

cmake should be in nativeBuildInputs instead. Not sure about flex and bison but probably those too.

Copy link
Member

@Mic92 Mic92 Sep 26, 2017

Choose a reason for hiding this comment

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

correct, cmake, flex and bison should be there.


preConfigure = ''
export MYSQL_INCLUDE_DIR=${mysql}/include/mysql
'';
Copy link
Member

Choose a reason for hiding this comment

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

-  preConfigure = ''
-    export MYSQL_INCLUDE_DIR=${mysql}/include/mysql
-  '';
+  MYSQL_INCLUDE_DIR="${mysql}/include/mysql";

@disassembler
Copy link
Member Author

It builds successfully now, and the service runs, but running icinga2 node wizard it tries writing to ${pkgs.icinga2}/etc. This can be set using CMAKE_INSTALL_SYSCONFDIR but the install scripts do more than just create directories for that path. If anyone has any suggestions on what can be done to make this work, I'm all ears.

@disassembler
Copy link
Member Author

Latest changes create a new variable for config directory separate from the one used that mkdir is ran using. It's a hack, but service runs, icinga2 node wizard works, and icinga2 service continued to run after restart. Next steps here are to enable database backend and create a web2 package that can be launched with a php-fpm service.

@disassembler
Copy link
Member Author

I don't use icinga2 anymore. If someone else wants to take this over, have fun, I'm closing.

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.

None yet

4 participants