knife node list VS knife exec -E 'nodes.all.each {|n| puts "#{n.name}"}'

258 views Asked by At

I'm trying to understand why the output of

knife node list

vs

knife exec -E 'nodes.all.each {|n| puts "#{n.name}"}'

Don't give me the same node names. I would expect the above commands to show me the same names but at the moment there are discrepancies, seems like any new node isn't picked up in the second command (knife exec..)

Any idea what might cause this and how to debug it?

1

There are 1 answers

0
Jeff On

Looking at the code for knife node list, it looks like this command will not output all of the nodes if you have an environment listed in your knife.rb file. It looks like running knife node exec returns the raw node object.

See the code here for knife node list: https://github.com/chef/chef/blob/f53ad6511b7fcc40576f05688dc17b11ad58e089/knife/lib/chef/knife/node_list.rb#L37-L40

See code here for the nodes object: https://github.com/chef/chef/blob/f53ad6511b7fcc40576f05688dc17b11ad58e089/lib/chef/shell/ext.rb#L461-L463