Knife SSH doesn't find my nodes

knife ssh isn't finding my nodes. I know it should be able to because when I can search for them I find them

# knife search node name:*
2 items found

Node Name:   web_01
...

Node Name:   admin
...

However, when I run knife ssh (I'll show it with the 'debug' flag) I get

# knife ssh "node:*" "uptime" -VV
DEBUG: Using configuration from /root/.chef/knife.rb
DEBUG: Signing the request as dev
DEBUG: Sending HTTP Request via GET to ec2-xx-xx-xx-xx.compute-1.amazonaws.com:4000/search/node
FATAL: No nodes returned from search!

(yes the host is correct, I just censored it for the post).

I've tried modifying the QUERY parameter and always get the same results. I've tried:

  • node:*
  • role:*
  • *
  • *:*

Any ideas?


I figured it out. my nodes did not have an fqdn. I had to specify -a ipaddress. the error message was not helpful. I figured it out by debugging knife ssh code. there is also a bug that it does not read the attribute from the knife config file. I'm going to open up a ticket about the issue and perhaps submit a patch.

What I did to get past this was put the hostname of the chef node in my /etc/hosts file with a pointer to the IP address. For example:

10.3.3.100 chef-client.int

You could, of course, always put it into a DNS server as well, along with the rest of your nodes. That would completely solve the problem.


Also, if -a ipaddress doesn't work, try -a cloud.public_ipv4

I was shown this solution after figuring out that knife ssh was trying to use internal IP addresses for my nodes and it took some asking in the chef IRC channel (#chef on irc.freenode.net) before someone named retr0h showed me this.