Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 11 down vote accepted

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.

share|improve this answer
5  
To clarify for other readers, "-a ipaddress" is literal. It apparently tells knife ssh to connect by IP not FQDN. This behaviour is dumb - it should fallback this way by default. –  Steve Bennett Jul 19 '12 at 2:24
    
@SteveBennett I agree that it should be default behavior. I see how my post can be confusing. Thanks for clarifying. –  Max Jul 19 '12 at 5:55
add comment

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.

share|improve this answer
add comment

Try knife ssh "id:*" "uptime".

Remember that knife ssh essentially does a knife search node, so your query should be one that works on knife search node (i.e., knife search node "node:*" doesn't work). knife ssh "role:*" should also work, but only if your nodes have roles assigned to them. For that matter, your original knife search node "name:*" should also work once you repurpose the query for knife ssh. So, knife ssh "name:*" "uptime".

share|improve this answer
1  
Thanks for the reply, but I bet "No nodes" for both id:* and name:* –  Max Jan 4 '12 at 12:42
    
OK, that's bizarre (i.e., it works for me). I've occasionally had to kick chef-solr to get new objects to show up in search, but, if you're getting results from "knife search node", you should be getting the same node list being used by "knife ssh". I don't know where to look next if the results list are different. –  cjc Jan 4 '12 at 12:49
add comment

Have you ever tried knife ssh "name:*" "uptime"?

I'm using chef 10.x and it works for me.

In my opinion, when using knife search [INDEX] [QUERY], the first parameter INDEX is used to specify type of the item to be queried. While using knife ssh command, it knows that you are tryting to search nodes, so all you have to do is specify the [QUERY] part, which is name:* in your case.

share|improve this answer
    
I thinks @cjc 's answer means the same. –  ley Jan 3 '13 at 7:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.