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.Try
knife ssh "id:*" "uptime"
.Remember that
knife ssh
essentially does aknife search node
, so your query should be one that works onknife 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 originalknife search node "name:*"
should also work once you repurpose the query forknife ssh
. So,knife ssh "name:*" "uptime"
.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 parameterINDEX
is used to specify type of the item to be queried. While usingknife ssh
command, it knows that you are tryting to search nodes, so all you have to do is specify the[QUERY]
part, which isname:*
in your case.I solved this by using ssh/config and connecting by the fqdn.