-
Notifications
You must be signed in to change notification settings - Fork 122
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: Templates #96
base: main
Are you sure you want to change the base?
WIP: Templates #96
Conversation
represents an action to perform or systemd service to restart when the secret changes
Co-authored-by: Winter <[email protected]>
Co-authored-by: Winter <[email protected]>
These secrets have a template file which refers to other secrets, which we splice in at activation time. This way we can have part of the file be secret, and part of it public.
I just realized there's an issue with this: what if we try to derive a template secret before its dependency is in place? Should we just decode all template secrets after all normal secrets? What about root secrets vs non-root secrets? I also think a good change to make would be to make a separate attribute: Will work on those later. |
Okay, I implemented all that. The code is more complex than I'd hoped... |
@Radvendii Thank you for your interest in improving agenix. I am not convinced that this template feature needs to be tightly integrated with agenix and suggest that you implement a separate (and general) templating module project that you can use activationScript deps to make run after agenix runs. |
There are three reasons I thought it best to include in agenix itself:
I won't push the matter any further though. If you think the added complexity is not worth the benefits for this project, I'll implement it separately. If you think it's somewhere in the range of reasonable, I'm happy to keep working at making the addition simpler. |
@Radvendii You're arguments are pretty compelling. I've also noticed a need for templating with secrets, but I've usually get around it by either moving the entire configuration file into the secret or using some configuration include option. I reopened the issue you made for this so we can think about it more. |
Yeah, that's the way I've done it also. Unfortunately, not all service's configurations have a way to redirect passwords to another file (two that I've encountered are msmtp and spotify passwords in mopidy). I would definitely say this is a deficiency of those projects, but it does seem to be somewhat common. And then putting the whole file in a secret does work. That's how I've been doing things. But it ends up with a lot of extra configuration being encrypted. The problem that someone else had recently that prompted me to actually try to code up a solution was that they had the same password used in two different configuration files. Right now they have to have two different secret files. Not the end of the world, but it would be nice to see an elegant solution to all these small issues. I'll think more about a more elegant design for this. |
So another way to structure this, which covers some of the use-cases but not all, is to have a Pros:
Cons:
|
We could
Pros:
Cons:
|
This seems to have gone stale :( The approach taken seems to be different to sops-nix's templating, but it looks like @Radvendii arrived at this alternative:
Which feels a lot closer to what IMO the biggest practical differences between
So it would be great to bring secret templating to I imagine that the approach in this PR is unwanted, given the resistance, and by now it's likely wildly outdated. I'd be happy to spend some time on a PR to introduce templating, would just appreciate some pointers on what would be an agreeable approach, where to start, and any potential gotchas. edit: I was too quick to comment. I see that @jhillyerd's implementation as mentioned in another comment achieves this. Perhaps this could be incorporated into ryantm/agenix ? |
Feel free to use any of my implementation, it's been working fine -- the potential downside being that it's only lightly used in a homelab setting, and I haven't written any tests for it. IMO, it would be best for the nix community if sops and agenix used very similar template syntax, but they don't share the same license so copy-pasting would probably be a bad idea. |
@jhillyerd thanks for your quick response 🙂 I think there would be significant value in splitting your implementation out into its own flake, alongside a good README which would hopefully come up in search results for What do you say? If you're not able to put in the time, I'd be happy to do so. |
@jhillyerd have you considered my proposition? In the meantime, I've been using your module with great success, having copy pasted it, just would be nice to not need to copy paste :) |
Yeah, I'll take a shot at it in the next week or two |
@jhillyerd yaay! the internet thanks you ❤️ |
implements #95
updates, and thus depends on #87