hashicorp / terraform-provider-rancher

Terraform Rancher provider
https://www.terraform.io/docs/providers/rancher/
Mozilla Public License 2.0
35 stars 33 forks source link

[feature request] support cloud providers #75

Open doreplado opened 6 years ago

doreplado commented 6 years ago

I looked through resource_rancher_host.go and was trying to figure out if this provider supports the various cloud providers for host provisioning that rancher supports.

Based on my research it doesn't yet.

Is there a way we could easily support the various cloud providers by making an optional appended system map to the host resource and pass in the json for the rancher-api to leverage the cloud provider?

Something like:

# Manage an existing Rancher host
resource rancher_host "foo" {
  name           = "foo"
  description    = "The foo node"
  environment_id = "1a5"
  hostname       = "foo.example.com"
  labels {
    role = "database"
  }
 provider {
    "amazonec2Config": {
        "accessKey": "XXXXXXXXXXXXXXXX",
        "ami": "ami-5c66ea23",
        "blockDurationMinutes": "0",
        "deviceName": "/dev/sda1",
        "endpoint": "",
        "iamInstanceProfile": "my-iam-profile",
        "instanceType": "t2.xlarge",
        "keypairName": "",
        "privateAddressOnly": true,
        "region": "us-east-1",
        "retries": "5",
        "rootSize": "100",
        "secretKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "securityGroup": [
            "some-secgroup"
        ],
        "sessionToken": "",
        "spotPrice": "0.50",
        "sshKeypath": "",
        "sshUser": "ubuntu",
        "subnetId": "subnet-ffffffff",
        "tags": "",
        "type": "amazonec2Config",
        "userdata": "",
        "volumeType": "gp2",
        "vpcId": "vpc-99999999",
        "zone": "b"
    },
    "engineInstallUrl": "https://releases.rancher .com/install-docker/17.09.sh",
    "engineStorageDriver": "overlay2",
    "hostname": "foo.example.com",
    "labels": {},
    "type": "host"
  }
}
raphink commented 6 years ago

That would be doable indeed. That said, we haven't implemented it because we prefer to manage provisioning with the proper Terraform resources, as managing it with Rancher will make it harder to patch/remove such resources.

doreplado commented 6 years ago

Isn't the provider using the Rancher API to begin with?

I'm probably not understanding correctly, but I thought if you're using the API and you do a remove call, it'll still remove the cloud resource. Basically you're just defining extra information about the host that the API supports that the terraform provider doesn't currently expose?

doreplado commented 6 years ago

nevermind, I think I understand your point. I think its less about removal and more about modification and tracking the state of the individual descriptors in that appended "blob"?

raphink commented 6 years ago

Yes indeed, that's the idea. Provisioning a host through Rancher kind of prevents you from managing its lifecycle.