Deleting nodes/clients using chef-client or chef-shell

Hello all,

I am currently using autoscaling on AWS combined with an init script (https://github.com/ameir/chef-initstrap) to bootstrap nodes. So far, it’s been working great.

One thing I’d like to do, though, is be able to delete the corresponding node/client from the Chef server on an instance termination. For autoscaled instances, I can put some meat in the stop action of the script to perform the deletion, but neither chef-shell nor chef-client appear to support such a method.

I just realized through some testing (while writing this email) that I can use knife from the servers like:

knife node delete hostname -f -c /etc/chef/client.rb
knife client delete hostname -f -c /etc/chef/client.rb

Would this be the preferred approach? I’m sure this is common enough of a problem.

Any feedback would be appreciated.

Thanks,
Ameir

knife will indeed work, I opened
https://tickets.opscode.com/browse/CHEF-5166 for exactly the use case
you described.

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Mon, May 19, 2014 at 12:56 PM, ameirh@gmail.com ameirh@gmail.com wrote:

Hello all,

I am currently using autoscaling on AWS combined with an init script
(https://github.com/ameir/chef-initstrap) to bootstrap nodes. So far, it's
been working great.

One thing I'd like to do, though, is be able to delete the corresponding
node/client from the Chef server on an instance termination. For autoscaled
instances, I can put some meat in the stop action of the script to perform
the deletion, but neither chef-shell nor chef-client appear to support such
a method.

I just realized through some testing (while writing this email) that I can
use knife from the servers like:

knife node delete hostname -f -c /etc/chef/client.rb
knife client delete hostname -f -c /etc/chef/client.rb

Would this be the preferred approach? I'm sure this is common enough of a
problem.

Any feedback would be appreciated.

Thanks,
Ameir