Delete node and client when destroying Vagrant VM


#1

I was trying to find a solution for that on the web, and the two references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/

Neither worked out of the box, so I hacked my own solution, adapting a bit from each, and came to this:

Feel free to use it if you find it useful. Comments and suggestions are welcome.

Cheers!

Cassiano Leal


#2

You can check out the code in my chef-sandbox that does this using the
vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

Change:

::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’, ‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal cassianoleal@gmail.comwrote:

I was trying to find a solution for that on the web, and the two
references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a bit
from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are
welcome.

Cheers!

Cassiano Leal


#3

meant to say “no subshell” not “syscall”

On Thu, Dec 6, 2012 at 11:04 PM, Jesse Nelson spheromak@gmail.com wrote:

You can check out the code in my chef-sandbox that does this using the
vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

Change:

::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’, ‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal cassianoleal@gmail.comwrote:

I was trying to find a solution for that on the web, and the two
references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a
bit from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are
welcome.

Cheers!

Cassiano Leal


#4

Nice one.

Just one correction to my original post, the link to my gist is https://gist.github.com/4223941 and not the one I sent before (that was a reference).

I like your REST approach, though, and will certainly have a look at that.

Thanks,

Cassiano Leal

On Thursday, December 6, 2012 at 12:04, Jesse Nelson wrote:

meant to say “no subshell” not “syscall”

On Thu, Dec 6, 2012 at 11:04 PM, Jesse Nelson <spheromak@gmail.com (mailto:spheromak@gmail.com)> wrote:

You can check out the code in my chef-sandbox that does this using the vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

Change:
::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’, ‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

I was trying to find a solution for that on the web, and the two references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a bit from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are welcome.

Cheers!

Cassiano Leal


#5

I seem to recall someone from Opscode steering people away from making
direct calls using Chef’s internal REST client for some reason. I’d do it
through the Knife object, something like (untested code alert):

Chef::knife::ClientDelete.run(env[:vm].config.vm.host_name)

On Thu, Dec 6, 2012 at 7:48 AM, Cassiano Leal cassianoleal@gmail.comwrote:

Nice one.

Just one correction to my original post, the link to my gist is
https://gist.github.com/4223941 and not the one I sent before (that was a
reference).

I like your REST approach, though, and will certainly have a look at that.

Thanks,

Cassiano Leal

On Thursday, December 6, 2012 at 12:04, Jesse Nelson wrote:

meant to say “no subshell” not “syscall”

On Thu, Dec 6, 2012 at 11:04 PM, Jesse Nelson spheromak@gmail.com wrote:

You can check out the code in my chef-sandbox that does this using the
vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

Change:

::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’, ‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal cassianoleal@gmail.comwrote:

I was trying to find a solution for that on the web, and the two
references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a bit
from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are
welcome.

Cheers!

Cassiano Leal


#6

It would be nice to know the reasoning behind not using the REST client.

When I have the time, I’ll experiment with both before deciding the way forward.

Thanks!

Cassiano Leal

On Friday, December 7, 2012 at 15:58, steve . wrote:

I seem to recall someone from Opscode steering people away from making direct calls using Chef’s internal REST client for some reason. I’d do it through the Knife object, something like (untested code alert):

Chef::knife::ClientDelete.run(env[:vm].config.vm.host_name)

On Thu, Dec 6, 2012 at 7:48 AM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

Nice one.

Just one correction to my original post, the link to my gist is https://gist.github.com/4223941 and not the one I sent before (that was a reference).

I like your REST approach, though, and will certainly have a look at that.

Thanks,

Cassiano Leal

On Thursday, December 6, 2012 at 12:04, Jesse Nelson wrote:

meant to say “no subshell” not “syscall”

On Thu, Dec 6, 2012 at 11:04 PM, Jesse Nelson <spheromak@gmail.com (mailto:spheromak@gmail.com)> wrote:

You can check out the code in my chef-sandbox that does this using the vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

Change:
::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’, ‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

I was trying to find a solution for that on the web, and the two references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a bit from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are welcome.

Cheers!

Cassiano Leal


#7

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” cassianoleal@gmail.com wrote:

It would be nice to know the reasoning behind not using the REST client.

When I have the time, I’ll experiment with both before deciding the way
forward.

Thanks!

Cassiano Leal

On Friday, December 7, 2012 at 15:58, steve . wrote:

I seem to recall someone from Opscode steering people away from making
direct calls using Chef’s internal REST client for some reason. I’d do
it through the Knife object, something like (untested code alert):

Chef::knife::ClientDelete.run(env[:vm].config.vm.host_name)

On Thu, Dec 6, 2012 at 7:48 AM, Cassiano Leal cassianoleal@gmail.com
wrote:

Nice one.

Just one correction to my original post, the link to my gist is
https://gist.github.com/4223941 https://gist.github.com/4223941 and not
the one I sent before (that was a reference).

I like your REST approach, though, and will certainly have a look at that.

Thanks,

Cassiano Leal

On Thursday, December 6, 2012 at 12:04, Jesse Nelson wrote:

meant to say “no subshell” not “syscall”

On Thu, Dec 6, 2012 at 11:04 PM, Jesse Nelson spheromak@gmail.com wrote:

You can check out the code in my chef-sandbox that does this using the
vagrant provisioner class and chef client code directly (no syscall:

https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L96

<https://github.com/spheromak/chef-sandbox/blob/develop/Vagrantfile#L52-L9
6>

Change:

::Chef::Config.from_file(File.join( File.dirname(FILE), ‘chef’,
‘knife.rb’))

To point to your knife.rb location.
Pop the rest in your vagrant file, and you should be good.

On Thu, Dec 6, 2012 at 9:03 PM, Cassiano Leal cassianoleal@gmail.com
wrote:

I was trying to find a solution for that on the web, and the two
references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm
-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a
bit from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are
welcome.

Cheers!

Cassiano Leal


#8

I wrote a Chef API wrapper with a clean DSL that you can find here: https://github.com/reset/ridley. You should be able to very easily destroy the client/node with just a few lines of code.

On a side note this is a good point that we don’t clean up after ourselves when we destroy a Vagrant VM. I’m not sure if you are using Berkshelf or not, but I’m going to create a ticket so when using the Chef Client provisioner that there is a configurable option to enable “clean up” on destroy.


Jamie Winsor
@resetexistence

On Thursday, December 6, 2012 at 4:03 AM, Cassiano Leal wrote:

I was trying to find a solution for that on the web, and the two references that made more sense were:

http://frank.be/articles/2011/12/16/vagrant-and-chef-auto-deregister-on-vm-destroy/
https://gist.github.com/1010660

Neither worked out of the box, so I hacked my own solution, adapting a bit from each, and came to this:

https://gist.github.com/1010660

Feel free to use it if you find it useful. Comments and suggestions are welcome.

Cheers!

Cassiano Leal


#9

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#10

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#11

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#12

I see that you opened that ticket on Berkshelf, but wouldn’t it make more sense if Vagrant’s chef_client provisioner would do that job instead? After all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#13

It probably is more appropriate to put it into Vagrant’s chef_client provisioner


Jamie Winsor
@resetexistence

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more sense if Vagrant’s chef_client provisioner would do that job instead? After all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#14

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more sense if Vagrant’s chef_client provisioner would do that job instead? After all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#15

I created pull requests on the Vagrant issue (https://github.com/mitchellh/vagrant/issues/1253). Chime in with your opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more sense if Vagrant’s chef_client provisioner would do that job instead? After all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of thing I wanted to understand. I’ll study both approaches before I decide which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using Berkshelf, and having that sort of functionality built into Vagrant would be fantastic. Let me know the ticket number when you create it so that I can chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from you. For example, we’d like to some day remove the json_class stuff from the API, which means that the data you get back from Chef::REST will probably be a Hash instead of a Chef::Node (or whatever you asked for). If (continuing the example) you use the methods on Chef::Node, you wouldn’t be impacted by this. Contrarily, the higher up the chain you go, there’s more things that could be changed. As a concrete example, the #save method is defined on all of the model classes to try to update and then fall back to create (or vice versa, it’s not 100% consistent). We’d like to change this at some point so there are separate create and update methods since 99% of the time you know which one you need.

Either way, changes to the API or to core model class functionality are generally only going to be shipped with major releases (e.g., 10.x -> 11.x) and we’ll do our best to document them and announce them ahead of time on this mailing list (upcoming changes in Chef 11, for example: http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


#16

I believe Mitchell has closed, time ago, a similar issue:

Here some of the reasons he gave:
"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.
"

On Sun, Dec 9, 2012 at 6:26 PM, Cassiano Leal cassianoleal@gmail.com wrote:

I created pull requests on the Vagrant issue
(https://github.com/mitchellh/vagrant/issues/1253). Chime in with your
opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client
provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more
sense if Vagrant’s chef_client provisioner would do that job instead? After
all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of
thing I wanted to understand. I’ll study both approaches before I decide
which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using
Berkshelf, and having that sort of functionality built into Vagrant would be
fantastic. Let me know the ticket number when you create it so that I can
chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” cassianoleal@gmail.com wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from
you. For example, we’d like to some day remove the json_class stuff from the
API, which means that the data you get back from Chef::REST will probably be
a Hash instead of a Chef::Node (or whatever you asked for). If (continuing
the example) you use the methods on Chef::Node, you wouldn’t be impacted by
this. Contrarily, the higher up the chain you go, there’s more things that
could be changed. As a concrete example, the #save method is defined on all
of the model classes to try to update and then fall back to create (or vice
versa, it’s not 100% consistent). We’d like to change this at some point so
there are separate create and update methods since 99% of the time you know
which one you need.

Either way, changes to the API or to core model class functionality are
generally only going to be shipped with major releases (e.g., 10.x -> 11.x)
and we’ll do our best to document them and announce them ahead of time on
this mailing list (upcoming changes in Chef 11, for example:
http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


Juanje


#17

Interesting thoughts.

The way I implemented it requires knife to be configured in the host, or at least a knife.rb pointing to the chef server and the client key (and probably client name as well). By default it looks for knife.rb in ~/.chef/knife.rb, but that can be overridden in the provisioner. Options could be added for those to be defined in the Vagrantfile itselfas an alternative for a full-on knife.rb.

The whole thing could be made optional, but I don’t think it’s necessary since all it does when it fails is to throw a warning and carry on. The implementation is not complicated at all and works pretty well. You can check the code in the pull requests I made.


Cassiano Leal

On Monday, December 10, 2012 at 02:35, Juanje Ojeda Croissier wrote:

I believe Mitchell has closed, time ago, a similar issue:
https://github.com/mitchellh/vagrant/issues/336#issuecomment-3100510

Here some of the reasons he gave:
"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.
"

On Sun, Dec 9, 2012 at 6:26 PM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

I created pull requests on the Vagrant issue
(https://github.com/mitchellh/vagrant/issues/1253). Chime in with your
opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client
provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more
sense if Vagrant’s chef_client provisioner would do that job instead? After
all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of
thing I wanted to understand. I’ll study both approaches before I decide
which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using
Berkshelf, and having that sort of functionality built into Vagrant would be
fantastic. Let me know the ticket number when you create it so that I can
chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from
you. For example, we’d like to some day remove the json_class stuff from the
API, which means that the data you get back from Chef::REST will probably be
a Hash instead of a Chef::Node (or whatever you asked for). If (continuing
the example) you use the methods on Chef::Node, you wouldn’t be impacted by
this. Contrarily, the higher up the chain you go, there’s more things that
could be changed. As a concrete example, the #save method is defined on all
of the model classes to try to update and then fall back to create (or vice
versa, it’s not 100% consistent). We’d like to change this at some point so
there are separate create and update methods since 99% of the time you know
which one you need.

Either way, changes to the API or to core model class functionality are
generally only going to be shipped with major releases (e.g., 10.x -> 11.x)
and we’ll do our best to document them and announce them ahead of time on
this mailing list (upcoming changes in Chef 11, for example:
http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


Juanje

http://about.me/juanje


#18

Throw a templated script in /etc/rc0.d (or your favorite equivalent that runs in runlevel 0, which is the important part) that looks something like this:

/path/to/knife node delete <%= node.name %> -y -c /etc/chef/client.rb
/path/to/knife client delete <%= node.name %> -y -c /etc/chef/client.rb

Easy recipe to write and no patches required. I do this in AWS autoscaling groups to keep my host chef costs down – it works.

-Erik

On Dec 10, 2012, at 2:20 AM, Cassiano Leal cassianoleal@gmail.com wrote:

Interesting thoughts.

The way I implemented it requires knife to be configured in the host, or at least a knife.rb pointing to the chef server and the client key (and probably client name as well). By default it looks for knife.rb in ~/.chef/knife.rb, but that can be overridden in the provisioner. Options could be added for those to be defined in the Vagrantfile itselfas an alternative for a full-on knife.rb.

The whole thing could be made optional, but I don’t think it’s necessary since all it does when it fails is to throw a warning and carry on. The implementation is not complicated at all and works pretty well. You can check the code in the pull requests I made.


Cassiano Leal

On Monday, December 10, 2012 at 02:35, Juanje Ojeda Croissier wrote:

I believe Mitchell has closed, time ago, a similar issue:
https://github.com/mitchellh/vagrant/issues/336#issuecomment-3100510

Here some of the reasons he gave:
"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.
"

On Sun, Dec 9, 2012 at 6:26 PM, Cassiano Leal cassianoleal@gmail.com wrote:

I created pull requests on the Vagrant issue
(https://github.com/mitchellh/vagrant/issues/1253). Chime in with your
opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client
provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make more
sense if Vagrant’s chef_client provisioner would do that job instead? After
all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort of
thing I wanted to understand. I’ll study both approaches before I decide
which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using
Berkshelf, and having that sort of functionality built into Vagrant would be
fantastic. Let me know the ticket number when you create it so that I can
chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” cassianoleal@gmail.com wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes from
you. For example, we’d like to some day remove the json_class stuff from the
API, which means that the data you get back from Chef::REST will probably be
a Hash instead of a Chef::Node (or whatever you asked for). If (continuing
the example) you use the methods on Chef::Node, you wouldn’t be impacted by
this. Contrarily, the higher up the chain you go, there’s more things that
could be changed. As a concrete example, the #save method is defined on all
of the model classes to try to update and then fall back to create (or vice
versa, it’s not 100% consistent). We’d like to change this at some point so
there are separate create and update methods since 99% of the time you know
which one you need.

Either way, changes to the API or to core model class functionality are
generally only going to be shipped with major releases (e.g., 10.x -> 11.x)
and we’ll do our best to document them and announce them ahead of time on
this mailing list (upcoming changes in Chef 11, for example:
http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


Daniel DeLeo


Juanje

http://about.me/juanje


#19

Back in March, I wrote about a multi-vm vagrantfile I use for testing0.
One of the commenters posted a snippet to add at the very end of the file
to automatically cleanup. As a disqus comment, it didn’t format well, but
I posted it here. Thanks, Eric Edgar for this!

-joshua

/

On 12/9/12 9:35 PM, “Juanje Ojeda Croissier” juanje.ojeda@gmail.com
wrote:

I believe Mitchell has closed, time ago, a similar issue:
https://github.com/mitchellh/vagrant/issues/336#issuecomment-3100510

Here some of the reasons he gave:
"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.
"

On Sun, Dec 9, 2012 at 6:26 PM, Cassiano Leal cassianoleal@gmail.com
wrote:

I created pull requests on the Vagrant issue
(https://github.com/mitchellh/vagrant/issues/1253). Chime in with your
opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client
provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make
more
sense if Vagrant’s chef_client provisioner would do that job instead?
After
all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort
of
thing I wanted to understand. I’ll study both approaches before I decide
which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using
Berkshelf, and having that sort of functionality built into Vagrant
would be
fantastic. Let me know the ticket number when you create it so that I
can
chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” cassianoleal@gmail.com wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes
from
you. For example, we’d like to some day remove the json_class stuff
from the
API, which means that the data you get back from Chef::REST will
probably be
a Hash instead of a Chef::Node (or whatever you asked for). If
(continuing
the example) you use the methods on Chef::Node, you wouldn’t be
impacted by
this. Contrarily, the higher up the chain you go, there’s more things
that
could be changed. As a concrete example, the #save method is defined on
all
of the model classes to try to update and then fall back to create (or
vice
versa, it’s not 100% consistent). We’d like to change this at some
point so
there are separate create and update methods since 99% of the time you
know
which one you need.

Either way, changes to the API or to core model class functionality are
generally only going to be shipped with major releases (e.g., 10.x ->
11.x)
and we’ll do our best to document them and announce them ahead of time
on
this mailing list (upcoming changes in Chef 11, for example:
http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.


#20

That’s exactly the same approach I took (bar a few technicalities). I like the approach, it works great.

My point, though, is that I shouldn’t need to go into my Vagrantfiles and paste into each one of them the exact same snippet of code in order to achieve something that’s really no more than the reverse of what Vagrant did when it spun up the VM.

I’m using my patched Vagrant, and so far it’s been flawless! :slight_smile:


Cassiano Leal

On Tuesday, December 11, 2012 at 03:41, Joshua Timberman wrote:

Back in March, I wrote about a multi-vm vagrantfile I use for testing0.
One of the commenters posted a snippet to add at the very end of the file
to automatically cleanup. As a disqus comment, it didn’t format well, but
I posted it here. Thanks, Eric Edgar for this!

https://gist.github.com/38ad69522a8eeb5f52be

-joshua

/

On 12/9/12 9:35 PM, “Juanje Ojeda Croissier” <juanje.ojeda@gmail.com (mailto:juanje.ojeda@gmail.com)>
wrote:

I believe Mitchell has closed, time ago, a similar issue:
https://github.com/mitchellh/vagrant/issues/336#issuecomment-3100510

Here some of the reasons he gave:
"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.
"

On Sun, Dec 9, 2012 at 6:26 PM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)>
wrote:

I created pull requests on the Vagrant issue
(https://github.com/mitchellh/vagrant/issues/1253). Chime in with your
opinions and comments!


Cassiano Leal

On Saturday, December 8, 2012 at 19:05, Cassiano Leal wrote:

https://github.com/mitchellh/vagrant/issues/1253

I wonder if we can close the one in Berkshelf.


Cassiano Leal

On Saturday, December 8, 2012 at 16:08, Jamie Winsor wrote:

It probably is more appropriate to put it into Vagrant’s chef_client
provisioner


Jamie Winsor
@resetexistence
https://github.com/reset

On Saturday, December 8, 2012 at 7:16 AM, Cassiano Leal wrote:

I see that you opened that ticket on Berkshelf, but wouldn’t it make
more
sense if Vagrant’s chef_client provisioner would do that job instead?
After
all, it’s Vagrant who creates the client and node in the Chef server.


Cassiano Leal

On Friday, December 7, 2012 at 22:58, Jamie Winsor wrote:

Here is the ticket: https://github.com/RiotGames/berkshelf/issues/264


Jamie Winsor
@resetexistence
https://github.com/reset

On Friday, December 7, 2012 at 3:48 PM, Cassiano Leal wrote:

Wow, thanks for the enlightening answer Daniel, that’s exactly the sort
of
thing I wanted to understand. I’ll study both approaches before I decide
which one to go with.

Jamie: Ridley looks great, thanks for writing that. Also yeah, I’m using
Berkshelf, and having that sort of functionality built into Vagrant
would be
fantastic. Let me know the ticket number when you create it so that I
can
chime in, if you don’t mind!

Adam: that comment made my afternoon! :slight_smile:

Cheers guys!

Cassiano Leal

On Friday, December 7, 2012 at 18:24, Daniel DeLeo wrote:

On Friday, December 7, 2012 at 11:29 AM, Adam Jacob wrote:

Use the REST api like a boss, man. That’s what it is there for.

Adam

On 12/7/12 10:17 AM, “Cassiano Leal” <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

It would be nice to know the reasoning behind not using the REST client.

The higher up the chain you go, the more places we have to hide changes
from
you. For example, we’d like to some day remove the json_class stuff
from the
API, which means that the data you get back from Chef::REST will
probably be
a Hash instead of a Chef::Node (or whatever you asked for). If
(continuing
the example) you use the methods on Chef::Node, you wouldn’t be
impacted by
this. Contrarily, the higher up the chain you go, there’s more things
that
could be changed. As a concrete example, the #save method is defined on
all
of the model classes to try to update and then fall back to create (or
vice
versa, it’s not 100% consistent). We’d like to change this at some
point so
there are separate create and update methods since 99% of the time you
know
which one you need.

Either way, changes to the API or to core model class functionality are
generally only going to be shipped with major releases (e.g., 10.x ->
11.x)
and we’ll do our best to document them and announce them ahead of time
on
this mailing list (upcoming changes in Chef 11, for example:
http://wiki.opscode.com/display/chef/Breaking+Changes+in+Chef+11 ).

In conclusion, there are trade-offs either way, but both ways are valid.