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

Rancher provider try to access the API on "plan" #10945

Closed
seb2411 opened this issue Dec 28, 2016 · 4 comments
Closed

Rancher provider try to access the API on "plan" #10945

seb2411 opened this issue Dec 28, 2016 · 4 comments

Comments

@seb2411
Copy link

seb2411 commented Dec 28, 2016

Terraform version: 8.2
Affected Resource(s) rancher provider

Hello I try to test the Rancher provider. But I face a problem and I don't know if it's a normal behavior or a bug.

My terraform scripts are setting up a cluster including a Rancher server and 7 hosts. My plan is, once the rancher server is working, to create a registration token using the rancher provider (ressource: rancher_registration_token) , and executing the command the resource is returning on each host to add this hosts on the Rancher cluster.

But it seem that the Rancher provider try to access the rancher API before the resource exist when executing the "terraform plan" command

My script

provider "rancher" {
  api_url = "http://${scaleway_server.rancher.private_ip}:8080"
  access_key = "${var.rancherAccessKey}"
  secret_key = "${var.rancherSecretKey}"
}

resource "rancher_registration_token" "default" {
  name = "serversRegistrationToken"
  description = "Registration token for the default environment"
  environment_id = "1a5"
}

the scaleway_server.rancher.private_ip is the private IP of the Rancher server.

the error I got:

Error refreshing state: 1 error(s) occurred:
* Get /v1: unsupported protocol scheme ""

If I replace the api_url by a random url like that:

provider "rancher" {
  api_url = "http://localhost:8080"
  access_key = "${var.rancherAccessKey}"
  secret_key = "${var.rancherSecretKey}"
}

I got the following message:

Error refreshing state: 1 error(s) occurred:
* Get http://localhost:8080//v1: dial tcp 127.0.0.1:8080: getsockopt: connection refused

As I understand the Rancher provider try to access the rancher server API on "terraform plan". And I expect this provider to contact the rancher onlywhen the rancher is ready (resource scaleway_server.rancher.private_ip ready)

@seb2411
Copy link
Author

seb2411 commented Dec 28, 2016

#9173

@johnrengelman
Copy link
Contributor

johnrengelman commented Jan 28, 2017

Well, Terraform has to talk to Rancher during a plan in order to refresh resource state.
I'm pretty sure you can't interpolate attributes from resources into providers like you are trying to do.
The providers are evaluated long before the resources in the graph. @stack72, right?

I don't believe this is an issue with the Rancher provider.

@ap1969
Copy link

ap1969 commented Apr 7, 2018

Did anyone ever find a solution to this? I'm trying to create the rancher server and reference it to assign hosts, but cannot find a way to do this in the same plan. However, if I use different plans, I can't find a way to share state (so the rancher IP is exposed automatically) without each plan trying to delete the resources created in the other...

Any thoughts?

@ghost
Copy link

ghost commented Apr 3, 2020

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.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants