-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Add rancher_host resource type #11545
Conversation
/cc @johnrengelman any take on this? |
Hmm, I see what you're trying to do here, but personally I wouldn't use TF to manage these things because I think the experience would be frustrating with TF not creating the host. You're effectively using the |
I think the if we were to implement this resource, then the only appropriate way to do it would be to call the host provisioning APIs in Rancher and manage the host that way. |
I think this is going to lead us into the conversation about supporting the
|
@johnrengelman I vote for for option 3. The only issue I see there is if you change the api version from v1 to v2 upgrade logic would need to be created (I assume that would require logic for destroying a v1 host and creating a new v2 host). |
@cpoole I don't believe that's the case in Rancher. A Host created in Rancher is available under either the v1 or the v2-beta api. It's just changing the API to do those things (the JSON definition and such). |
Pretty sure of that, too (re v2). By the way, while the v2 API is marked beta, it is finalized and will not move (confirmed from Rancher employee). @johnrengelman I do want to manage hosts in Terraform though, so that I can autoscale some environments cleanly, which is not possible if I can't remove hosts from Rancher when I shut down nodes. And using rancher hosts to create them is not a good option imo, as it will dynamically create security groups and such, which won't be purgeable in Terraform, so I'd rather control how things are done cleanly, using Terraform. |
@raphink that's How I manage hosts as well...Use TF to create a Launch Configuration and ASG so when the instance launches it joins in. In this case, TF would never come into play with the hosts and I image an out-of-band process to reap hosts would be a better solution than using TF to do (just IMO). I've been looking at this - https://github.com/ampedandwired/rancher-reaper but haven't tried it out yet. |
I agree with @johnrengelman. We have a lambda function that does this here at Daqri. I'll try and opensource it by end of next week. |
A |
Is this ready to merge? If so, please can it be rebased? |
@stack72 I'll have a look to see what's missing (and rebase) |
Just fixed and rebased. |
Example usage: resource rancher_host "wrk8" {
name = "wrk8"
description = "my fabulous machine"
environment_id = "1a113948"
hostname = "wrk8.example.com"
} |
@raphink still failing i'm afraid ;) |
Ok I'll need to check. I'll also add support for host labels. |
This adds a rancher_host resource type. For now, the goal is to detect if the host already exists, so that it can be purged cleanly when the host is deprovisioned. The typical use is to create both an instance (e.g. aws_instance) and a rancher_host resources with the same hostname. The rancher_host resource will detect when the agent has registered itself. When removing the host, both the instance and the rancher_host resources can be removed, ensuring the host is purged from Rancher. In future versions, this could support creating hosts as well.
@stack72 I added host labels support. I've kept it (so far) as two patches, because there's a little hack linked to rancher/rancher#8165. Ideally, I'm hoping Rancher Labs will store their computed labels in another API so we don't need to filter these Also, build is now 💚 |
Thanks for all the work here @raphink :) |
Thanks for merging! |
* Add rancher_host resource type This adds a rancher_host resource type. For now, the goal is to detect if the host already exists, so that it can be purged cleanly when the host is deprovisioned. The typical use is to create both an instance (e.g. aws_instance) and a rancher_host resources with the same hostname. The rancher_host resource will detect when the agent has registered itself. When removing the host, both the instance and the rancher_host resources can be removed, ensuring the host is purged from Rancher. In future versions, this could support creating hosts as well. * Use ro_labels to avoid removing internal Rancher labels As reported in rancher/rancher#8165 * Do not ForceNew on environment_id
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Add rancher_host resource type
This adds a rancher_host resource type.
For now, the goal is to detect if the host already exists,
so that it can be purged cleanly when the host is deprovisioned.
The typical use is to create both an instance (e.g. aws_instance)
and a rancher_host resources with the same hostname. The rancher_host
resource will detect when the agent has registered itself.
When removing the host, both the instance and the rancher_host
resources can be removed, ensuring the host is purged from Rancher.
In future versions, this could support creating hosts as well.