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

Vagrant destroy should remove client and node from chef server #336

Closed
oliver-dungey opened this issue Mar 31, 2011 · 9 comments
Closed

Comments

@oliver-dungey
Copy link

When you use vagrant with Chef the first run of chef-client will register a new client and node with the chef server. When you issue a vagrant destroy command it does not delete the chef client and node. As a result developers find themselves continually bumping into the error "409: conflict, client already exists" every time they destroy a vagrant instance and this leads to wasted time. A great enhancement to vagrant would be to add some code to the destroy command would be the removal of the corresponding client and node from the chef server - this would allow people to repeatedly up/destroy images without the need for manual interaction each time.

@mitchellh
Copy link
Contributor

I agree, this needs to be a feature in Vagrant. Marked as a feature, no milestone yet.

@yfeldblum
Copy link

In the meantime, add to the docs:

$ knife client delete #{fqdn} --yes
$ knife node delete #{fqdn} --yes

@skippy
Copy link

skippy commented Jun 6, 2011

something like so? https://gist.github.com/1010660

@oliver-dungey
Copy link
Author

Nice one skippy

@mitchellh
Copy link
Contributor

Skippy, thanks for that. I plan on implementing something like that into Vagrant as a full on feature. I'll use that as inspiration.

@mitchellh
Copy link
Contributor

Hello all,

I've been thinking and working on this and I've ran into quite a few user-experience issues.

  • The easiest way to do this would be to use the Chef installation already in the VM to remove the node and such. However, during a destroy, if the node is already down, then SSH is not available. Requiring a VM to be up to destroy is not acceptable.
  • Using local knife from the Chef provisioner is another option, but requires knife to be installed. knife must also already be setup as a client of the Chef server, which it isn't by default. This may surprise people. An option is to make this feature an option which is disabled by default and only enable it via a provisioner option.
  • Vagrant can't use the Chef API directly because the computer might not be setup as a client and doing all that just to remove another node is often defeating the purpose and is also very complicated.

I do believe this is an important feature, but the complexity is rather high. Continuing with the plugin approach for users who need this may be the best approach. I'd like feedback.

Thoughts?

@yfeldblum
Copy link

With #3, ask the user for his credentials (username & private key file) on the chef-server.

@mitchellh
Copy link
Contributor

I've decided to actually leave this up to the user for now, due to a lack of good libraries for Chef.

@gmacid
Copy link

gmacid commented Jan 12, 2012

Just commenting on the original issue (as I just had it and decided to solve it like this)

I don't think extra features in vagrant are necessary with the following configuration:

client_key_path = "/certificates"

config.vm.define :some_node do |node_config|
node_config.vm.provision :chef_client do |chef|
chef.node_name = "some_node.local.net"
chef.client_key_path = "#{client_key_path}/some_node.pem"
end
app_config.vm.share_folder("certs", "#{client_key_path}", "./certificates", :owner => "root", :group => "root")

(Assuming you have a .gitignored writable certificates directory local to your Vagrantfile)

This way, the first time you generate, it will register under a different node name (than the traditional published vagrant-distribution.vagrantup.com image node name), and store the cert in a shared folder, which next time you down/up it, will have access to its certificate.

I would suggest being able to passthrough the client.pem as well as the validation.pem from host to guest as a way to solve it otherwise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants