Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete client with newline in name

Ok, so this started because I was trying to get auto-scaled nodes to self register with Chef. I had the following in my client.rb file:

node_name "some_prefix-#{`hostname`}"

the idea was that each node would have the same prefix but a hostname based suffix. Sadly, hostname returns a string with a \n on the end of it. Chef happily let me create this client, but it is unable to actually access it in any way.

knife client show some_prefix-myHostname
knife client show "some_prefix-myHostname\n"
knife client show "some_prefix-myHostname%0A"

all three result in a 404

knife client list

does show the client, and a blank newline after it.

I have fixed my client.rb template, but I can't get rid of the nodes I created with the newline in their names. I've tried using knife, the webui, and even manually using the Chef::REST library in irb, but everything results in a 404.

Any ideas?

EDIT: I have also tried knife client bulk delete but that fails as well. It appears that the REST library sanitizes the url and removes the newline before attempting to send the request.

like image 960
Tejay Cardon Avatar asked Nov 09 '22 16:11

Tejay Cardon


1 Answers

You can try using knife raw which lets you send requests directly to the Chef Server API

knife raw /nodes/<node-name>
knife raw delete -m /nodes/<node-name>

This worked for me on a similar issue with an invalid role name.

like image 65
Ron L Avatar answered Jan 04 '23 03:01

Ron L