c10l / vagrant-butcher

Delete Chef client and node when destroying Vagrant VM
MIT License
124 stars 12 forks source link

Trying to run Vagrant up with butcher gives problem #3

Closed mulderp closed 11 years ago

mulderp commented 11 years ago

Hello,

I installed butcher with:

vagrant gem install vagrant-butcher

But it somehow seems that the old client is still registered:

[2013-01-25T15:59:40+00:00] INFO: * Chef 10.16.2 * [2013-01-25T15:59:41+00:00] INFO: Setting the run_list to ["role[base]", "role[application]", "recipe[locomotive-cms]"] from JSON [2013-01-25T15:59:42+00:00] INFO: Run List is [role[base], role[application], recipe[locomotive-cms]] [2013-01-25T15:59:42+00:00] INFO: Run List expands to [apt, omnibus_updater, xml, git, nodejs, passenger_apache2, locomotive-cms] [2013-01-25T15:59:43+00:00] ERROR: Server returned error for https://api.opscode.com/organizations/fidor/reports/nodes/patrick_web_vm_2/runs, retrying 1/5 in 4s [2013-01-25T15:59:48+00:00] ERROR: Server returned error for https://api.opscode.com/organizations/fidor/reports/nodes/patrick_web_vm_2/runs, retrying 2/5 in 8s [2013-01-25T15:59:57+00:00] ERROR: Server returned error for https://api.opscode.com/organizations/fidor/reports/nodes/patrick_web_vm_2/runs, retrying 3/5 in 11s [2013-01-25T16:00:08+00:00] ERROR: Server returned error for https://api.opscode.com/organizations/fidor/reports/nodes/patrick_web_vm_2/runs, retrying 4/5 in 17s

Any idea how to fix this?

Thanks!

Patrick

c10l commented 11 years ago

When you destroyed the VM previously, did you see the messages about the node and client being deleted?

mulderp commented 11 years ago

Hm.. retrying now gives:

vagrant destroy web

Are you sure you want to destroy the 'web' VM? [Y/N] y [web] Forcing shutdown of VM... [web] Removing Chef node ""... [web] Could not remove node : 405 "Method Not Allowed" [web] Removing Chef client ""... [web] Could not remove client : 404 "Not Found" [web] Destroying VM and associated drives...

c10l commented 11 years ago

Do you have the host_name configured in the Vagrantfile? It should look like:

Vagrant::Config.run do |config|
  config.vm.host_name = "vagrant-vm-hostname"
end
mulderp commented 11 years ago

Thanks! I'll check; I am just in a provision run, but I will insert the lines above. Also, in my case, I don't use a host_name but IPs for connecting VMs. My Vagrantfile looks like this:

https://github.com/mulderp/learning-chef/blob/master/Vagrantfile

c10l commented 11 years ago

I see. I don't use the hostnames to connect to the VMs either, but chef takes the hostname and uses it as the node name. Currently, vagrant-butcher uses env[:vm].config.vm.host_name as the node and client name that will be passed to Chef for deletion. In your case, it finds no hostname and tries to delete node and client "" form the server, which is why you got the messages you mentioned when destroying. After you set the hostname in your Vagrantfile, you don't need the chef.node_name anymore. I see that you're using multi-VM Vagrantfiles, so make sure that you assign a different hostname for each VM the same you way you did chef.node_name. I'll close this issue for now, but feel free to drop a line if you stumble into any other trouble!

mulderp commented 11 years ago

indeed setting the host_name solves the problem. thanks! it's an interesting approach to use vagrant and hosted chef.

c10l commented 11 years ago

Cool, I'm glad it's working for you.

Usually, unless an isolated cookbook actually requires using a chef server, I try to use chef solo for my development cycles since it allows me to do much faster iterations.

I use vagrant mostly with an open source chef server that I installed in one of my local servers. It helps me test cookbooks against a chef server as opposed to using them on chef solo only. I also use vagrant to do integration tests of my cookbooks, and I like to have an environment as close to production as possible, and that involves the use of chef-client.

When I have the time I'll check the feasibility of using the actual chef node name instead of relying on the hostname.

mulderp commented 11 years ago

Wow, good to hear about the different setups strategies. I've tried chef-solo too, but I haven't yet a feeling for why/how it's giving faster feedback than chef-server.

Right now, I am writing my first cookbook; maybe I take the discussion to the chef mailing list, since I am having some questions: https://github.com/mulderp/learning-chef/tree/cms_role (app instance seems not to connect mongo instance)

c10l commented 11 years ago

To me, the use of chef server when developing a cookbook slows me down on two points. The first one is because I use Berkshelf for cookbook dependency management: every time I do a vagrant up or vagrant provision, it uploads every single cookbook dependency to the server, which in some cases takes up to 4 or 5 minutes. The second point of slowness is during node conversion, as it reports each step to the server and requests new info. This one depends a lot on how quick the server is responding, but doesn't usually cause a noticeable slowdown.