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

I can't import a machine with a clone block in it #333

Closed
djha-skin opened this issue Dec 20, 2017 · 7 comments
Closed

I can't import a machine with a clone block in it #333

djha-skin opened this issue Dec 20, 2017 · 7 comments
Labels
enhancement Type: Enhancement

Comments

@djha-skin
Copy link

Terraform Version

Terraform v0.11.1

vSphere Provider Version

.
├── provider.vsphere 1.1.1
├── provider.zenoss
└── module.ranchermgr
    ├── provider.null
    └── module.vsphere_instance
        ├── provider.external
        ├── provider.template
        ├── provider.vsphere (inherited)
        └── provider.zenoss (inherited)

Affected Resource(s)

  • vsphere_virtual_machine

Configuration File and Steps to Reproduce

Basically, I have a vsphere_virtual_machine block that has a clone block in it.

I do a terraform state rm <virtual-machine-object> and reimport it.
Finally, I run a terraform plan. I get an error message generated by this line of code.

Expected Behavior

It should say "nothing to do" on the terraform plan

Actual Behavior

It errors, saying I can't have a clone block

Comments

The error message says I must either delete the clone block from config or not import machines. But if I delete the clone block, I can't make new ones if I need them.

I can't use terraform to import machines and then manage them afterwards.

@almoore
Copy link

almoore commented Dec 20, 2017

+1

@vancluever vancluever added the enhancement Type: Enhancement label Dec 20, 2017
@vancluever
Copy link
Contributor

@djhaskin987 and @almoore, this is currently intended behaviour. Importing does not populate the clone sub-resource at all, hence on the next plan, it would force a new resource. This is blocked explicitly to prevent accidental deletion.

There have been some offline requests to change this behaviour and I can see the value in not duplicating your configs, as such I will mark this as an enhancement to see if we can find a better way. The challenge lies in the complexity of the structure of clone and customize and what we can do to ensure that block is ignored in the diff, yet still allow changes to force a new resource naturally.

@djha-skin
Copy link
Author

djha-skin commented Dec 20, 2017

This means that either I can import all my VMs, or I can clone them, but I can't do both. I can't tell Terraform how to make a new VM and also tell Terraform that a previously created one exists.

I understand that this is a complicated task and the vsphere soap api doesn't make it easier, but I can't really use this provider (or pitch it to the ops team) if I don't have the assurance that I can import resources while also being able to recreate them.

I appreciate your taking time and marking it an enhancement :)

@vancluever
Copy link
Contributor

@djhaskin987 to be fair, this is more of a TF issue than it is a vSphere issue. 🙂

I have some ideas around how this can be implemented, so it might be reasonable to see this in 1.2.0 or 1.3.0 in the new year. Stay tuned!

@djha-skin
Copy link
Author

djha-skin commented Dec 20, 2017

"not duplicating your configs" - does that mean there's a workaround involving using a few extra config blocks? If so, I welcome it and would happily use it instead. Is there such a workaround?

Also, Thanks!

@vancluever
Copy link
Contributor

@djhaskin987 yeah, importing those VMs with a config that doesn't have the clone block in it will be okay.

What I would do (personally, not saying this applies to your org) is just run the current projects out of a different config repo for now, maybe using a variation of your ranchermgr module that has had the clone block removed, but with the rest of the config intact.

Even further, if you are managing all of this with a module, it might just be as easy as forking the module for now, switching to that one, and then switching back either when you need to re-deploy those VMs (at that point, you should be able to taint the resources with terraform taint), or when we remove the restriction in a later release.

So sorta more config, and sorta less config. 🙂 But if you can deal with the divergence for now, it should work for you.

@vancluever
Copy link
Contributor

Hey all,

We just released 1.4.0 which lifts the import and legacy upgrade restrictions on the clone sub-resource block. There a few things you should know about how this functionality works (namely pertaining to configuration changes on the first apply post-import), so head over to Additional requirements and notes for
importing
in the resource documentation for more details on that. Otherwise, I hope this new functionality is useful and let us know if anyone has any issues!

@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants