-
Notifications
You must be signed in to change notification settings - Fork 123
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
Feature: restart systemd service when relevant secret updated #84
Comments
This is a great idea. How do you propose that a service's dependence on a secret be declared, though? (Instead of requiring the user to add a dependence on a secret to a service by manually, ideally there would be a cleaner solution that would let you specify the dependent services alongside the secrets.) |
This is what I added as a separate module to accomplish my goals:
This way you can either specify it with
or
Which might be useful for different actions than just restarting a given service (in this case the two examples are equivalent). |
I like this a lot, nice work. |
@Radvendii Would you be open to PRing this implementation? |
There are now The feature has been used by sops-nix to implement on demand systemd unit restart/reload. |
I would like to see a solution similar to sops-nix, where I just list the units to restart or reload. If this works via the activation script approach that would be convenient, especially if it can assert that the services I listed actually exist. In the meantime I'm tempted to just use Edit 2: |
|
@EHfive Is there a reason you say that |
Oh, of course. Sorry, I was being silly and didn't actually look at the Hmm... Thanks for bringing this up. I'm not sure what advantage it has over the approach I implemented with setting |
Ohhhhh as I say that I realize what the advantage is: they're comparing the decrypted files, so it won't reload if, for instance, you just rekey the secret. |
I think I ran into problems with this approach where we didn't have access to the old secrets while decrypting the new ones for some reason... |
Because the way
Given that, if I write That said, I was wrong about saying this might work fine with flakes. Flakes will copy the repo to the store so local changes produce new paths, but local changes anywhere in the repo will produce a new path. So you really do need the antiquotation always, to copy just that path to the store. I suppose you could write
I'm pointing this at the source file, not the decrypted file. And it's the path that matters for An activation script that compares the actual decrypted file would be best of course, as that would allow it to actually do things like compare user/group/mode and avoid spuriously reloading due to rekeying. |
I suppose you could modify the In theory agenix could actually define its secrets config to have a |
Ahhh I understand. Yes, I was confused. Seems like we thought of the same solution. What you're describing is what I've implemented in the PR (more or less). It puts the user, group, permissions, file, etc. in the |
If a systemd service depends on a secret, and agenix is managing that secret, it would be nice to restart the service on
nixos-rebuild switch
. Now, at the moment agenix has no way of knowing which service depends on what secret, so we could maybe add a field to specify that per-secret. Alternatively, a more general solution which is whatmorph
does, is to just add a field for a command (or maybe script) to be run when the secret is deployed / changes.The way I am currently managing this is via systemd paths:
I'm not sure if there is a better nix-internal way to do this, but it shouldn't be too hard to translate this solution into an agenix-internal one. I'm happy to implement it if people like the idea.
The text was updated successfully, but these errors were encountered: