-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Hetzner Cloud integration #10
Comments
Hi @bastelfreak! I prototyped this a little bit and wonder how to deal with SSH keys: Similarly to AWS, Hetzner requires you to set up SSH Keys (manual upload, or via API) before they can be used to provision servers. The AWS integration for beaker has a nice implementation that generates a unique name for an SSH Key, creates that in AWS in the provisioning phase and then removes the key again during cleanup. We could do the same, but there is a small caveat: Hetzner enforces uniqueness of keys. You cannot upload the same key with a different name. If you only ever run one beaker job at a time and always use a key that you never want to use within the same project in your hetzner account, this is not a problem. But when concurrent CI jobs are possible and/or you want to run jobs manually using the same key, things could get ugly. A slightly more robust approach could be to:
This way we would not clobber existing keys and could safely support different use cases using the same key. But still not concurrently Of course we could simply skip the cleanup of keys, but I would find that a bit messy. A cheap solution could be to simply skip management of SSH keys altogether. In that case a user would have to set up their key at hetzner in whichever way they prefer and then configure within beaker which key to use. This way we would be rid of all the problems mentioned above, but it would require more manual setup and be less "plug&play". What do you think? |
Is generation of SSH keys not cheap enough that you can generate a key for each individual run? beaker-vagrant does generate a |
@oneiros I agree with @ekohl here. I think generating ed25519 keys on the fly isn't that expensive. It doesn't require a lot of randomness and also not a lot of CPU time. We could generate one for each job, upload them to hetzner and maybe prefix them with |
I agree and it makes total sense to me. Being new to beaker and its ecosystem, I was not sure, what the expections were. beaker itself compiles a set of ssh options using existing keys from the user. The aws "hypervisor" builds on that and I thought it might be least surprising to stay as close to this behavior as possible. But given hetzner's constraints and the fact that a truly "plug&play" solution is probably even less error-prone, I will gladly go ahead with your suggestion. |
awesome, thanks! |
Offers limited options to customize server creation (choosing an image, server type and location by name). SSH keys are being generated on-the-fly building on the `ssh_data` gem.
I just opened PR #11 with my first attempt at an implementation that "works for me" ™️ Generating ed25519 keys from ruby turned out to be a bit trickier than expected. While there is the In the end I settled on Github's A couple of remarks with regards to the requirements mentioned above:
For now I opted to specify OS images by name. According to the docs this should work for both the ready-made images Hetzner provides as well as custom ones, i.e. VM snapshots stored in your account. I did however not test this.
I am not sure how and if this can be done. So instead I opted to add a paragraph about cleanup to the
Sorry, I am not sure what this actually means 🙂. I did provide an option to specify a datacenter location. Maybe that is it? (Note that Hetzner has multiple datacenters at these locations and indeed the API allows to name a specific datacenter instead of the location, but I thought giving the location should suffice as that is what you select when creating servers manually as well.) |
Thanks for all the work! I will try to review/test/respond in detail in the next couple of days. |
Initial implementation of hypervisor #10
Purpose
the purpose of this beaker-plugin is to extend beaker in a way that it can automatically provision servers at Hetzner Hcloud.
Background
Beaker, in combination with rspec and serverspec, is the acceptance testing framework. Beakers main job is to prepare an environment where we can run tests. The usual workflow is:
Beaker is very flexible and enhanced with plugins, usually one plugin per hypervisor. the most common ones are:
We've also some libs:
And some plugins that also work with other cloud vendors:
tasks in this gem
Hetzner provides ruby API bindings: https://rubygems.org/gems/hcloud. Whereever possible they should be used instead of the API: https://docs.hetzner.cloud/
The text was updated successfully, but these errors were encountered: