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

Teleport SSH/PKI Cluster Module: Init #93836

Closed
wants to merge 10 commits into from
Closed

Teleport SSH/PKI Cluster Module: Init #93836

wants to merge 10 commits into from

Conversation

Church-
Copy link

@Church- Church- commented Jul 25, 2020

Motivation for this change

Just a basic module for the clustered ssh daemon teleport since none existed.
Planning on a more nuanced module with a config section for each service that teleport offers/works with.

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.

I assume there's a doc that I'm missing, but where would I look to ensure documentation for the module is added to nixos.org?

@Church- Church- changed the title Adding a basic module for the teleport cluster ssh/pki service. Teleport SSH/PKI Cluster Module: Init Jul 25, 2020
Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

I have left a few questions and comments.

nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
Directory to store Teleport Service data.
'';
};
configText = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

Having a single settings option to represent this file might be worth looking into and match upstream more closely. What were aiming for by splitting this file into multiple? I'm not familiar with this program so don't know the pros and cons of doing so.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not certain what lines you're referring to here? Where am I splitting the file into multiple?

Copy link
Member

Choose a reason for hiding this comment

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

I was mentioning the note you made above:

  # This becomes the main config file
  # To be used in the future when I add seperate option sections for each part of teleport
  # Rather then writing a single yaml file directly into your nix file.

Since the file format is yaml this maps nicely to a nix attribute set. Very shortly nix will have even nicer support for this, see #75584 if interested.

Copy link
Author

@Church- Church- Jul 27, 2020

Choose a reason for hiding this comment

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

Ah my apologies, to be clear what I actually meant, was what you implied. Having sub services as attr sets that can be written to the yaml config file.

Rather then just encoding a flat yaml file directly in your nix expression when you enable this service.

Have some scaffolding in place now, and planning to commit the meat of it tomorrow afternoon once I'm off work.
Seems to be working so far from what I have.

Copy link
Author

Choose a reason for hiding this comment

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

This should now make more sense, with the changes I've made to define the service config file in nix expr lang.

nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/teleport.nix Outdated Show resolved Hide resolved
@Church-
Copy link
Author

Church- commented Jul 28, 2020

Revamped the teleport module so that one can now describe your config file in nix expr lang.

Still need descriptions and default values for each option however.

Also missing some options still I'm realizing.
Will add those tomorrow.

@Church-
Copy link
Author

Church- commented Jul 28, 2020

Hmm, failing. I'll add the defaults next. I assume that might be throwing it off. Since it works on my setup.

@aanderse
Copy link
Member

aanderse commented Aug 2, 2020

@Church- sorry for the delay. I've been meaning to put something together for you. How about something like this?

Just needs examples and descriptions.
@Church-
Copy link
Author

Church- commented Aug 2, 2020

@aanderse Interesting, just pushed the changes I had for my module.
Everything set via module now.

Just needs examples and descriptions.

Your fork is interesting, I'll admit. Will have to look over it and mull some more.

@Church-
Copy link
Author

Church- commented Aug 2, 2020

Looking over some more I do admit I do like the idea of having a user just set the attr set by them selves completely.

The only upper hand that my version has is:

  • self-documenting via examples/description for each option
  • has easy defaults baked in so someone could just deploy with just a
teleport = {
  enable = true;
  nodename = "foo";
  ... and so on ...
};

And have the ssh service already enabled by default.

@Church-
Copy link
Author

Church- commented Aug 2, 2020

Aware the change isn't evaling as well, seems I really need those descriptions and examples still. 😛

@Church-
Copy link
Author

Church- commented Aug 8, 2020

@aanderse Any thoughts?

@aanderse
Copy link
Member

@Church- the bot is saying "trace: warning: Option `services.teleport.advertise_ip\' has no description.". If you add a description field to every option I think you'll be in better shape.

@Church-
Copy link
Author

Church- commented Aug 12, 2020

@aanderse

Yep I'm aware! Just wanted your thoughts on the general structure of the module now.

@Church-
Copy link
Author

Church- commented Aug 15, 2020

@aanderse Yeah as I thought and you confirmed that was the issue.

So, what do you think of the general structure now? Any complaints or worthy to merge down?

@Church-
Copy link
Author

Church- commented Aug 16, 2020

I would actually hold off on reviewing this PR again until I push some new changes.

Somewhat funnily I've decided to end up going with an approach like yours @aanderse after talking with infinisil about his settings PR.

@stale
Copy link

stale bot commented Feb 12, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 12, 2021
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.teleport}/bin/teleport start ${cmdlineArgs}";
ExecReload = "/run/current-system/sw/bin/kill -HUP $MAINPID";
Copy link
Contributor

Choose a reason for hiding this comment

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

${pkgs.coreutils}/bin/kill maybe? 😉

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 21, 2021
Copy link
Contributor

@ymatsiuk ymatsiuk left a comment

Choose a reason for hiding this comment

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

Thanks for putting the effort into creating this module!

};

config = mkIf cfg.enable {
systemd.services.teleport = {
Copy link
Contributor

Choose a reason for hiding this comment

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

To join teleport node to the cluster we have to run teleport as root and it's ok to run auth and proxy as less privileged user. AFAICS we run always as root with this implementation, don't we?

@ymatsiuk
Copy link
Contributor

ymatsiuk commented Jan 7, 2022

I found some time to finish the work started here in #153825

@ymatsiuk ymatsiuk closed this Jan 12, 2022
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